Wilshire Posted August 17, 2006 Share Posted August 17, 2006 This isn't working for me at all, nothing shows up: <html><body><script type="text/javascript">var A=Number(prompt("Number:"));var B=Number(1);While (B<Math.pow(A,.5)){B++if (A%B==0){break}}if (B<Math.pow(A,.5)){document.write(A+" is a prime number.")}else{document.write(A+" is not a prime number.")}</script></body></html> Link to comment Share on other sites More sharing options...
aspnetguy Posted August 17, 2006 Share Posted August 17, 2006 give this a try <html><head> <title>...</title></head><body><script type="text/javascript"> var A = parseFloat(prompt("Number:")); var B = parseInt(1); while (B<Math.pow(A,.5)) { if (A%B == 0){document.write("nothing left.")} if (B<Math.pow(A,.5)) document.write(A+" is a prime number.") else document.write(A+" is not a prime number.") B++ }</script></body></html> Link to comment Share on other sites More sharing options...
Wilshire Posted August 17, 2006 Author Share Posted August 17, 2006 That didn't work, but it certainally helped. Final version: <html><body><script type="text/javascript">var A = Number(prompt("Number:"));var B = Number(2);while (B<A){if (A%B == 0){break}B++;}if (B<A){document.write(A+" is not a prime number.")}else{document.write(A+" is a prime number.")}</script></body></html> Link to comment Share on other sites More sharing options...
aspnetguy Posted August 17, 2006 Share Posted August 17, 2006 glad I could help out Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now