DHTML_XML2_10

<!DOCTYPE html> <html> <head> <title>Unit 2 - Q10</title> <script type="text/javascript"> var no=4,half,flag,i; document.write("No. to check for prime : " + no + "<br>"); half=no/2; for(i=2,flag=0;i<=half;i++) { if(no%i==0) { flag=0; break; } else flag=1; } if(no==2||no==3) flag=1; if(flag==1) document.write("Ans. : " + no + " is a prime no."); else document.write("Ans. : " + no + " is not a prime no."); </script> </head> </html>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.