Share on Google+Share on Google+

Azharul Islam Talukdar
Javascirpt Programing
1 Answer(s)      6 years and 5 months ago
Posted in : HTML

write a html page with javascript to check a number is prime or not.

Ads

View Answers

November 22, 2010 at 3:56 PM


Hi Friend,

Try the following code:

<script type="text/javascript">
function check(){
            var num=document.getElementById('num').value;
            var i=2;
            var b;
            var status = true;
        while(i<num)
            {
                b=num%i;
                if(b==0)
                {
                    status = false;
                    break;
                }
                i++;
            }


            if (status)
            {
                alert("Your number is a prime number");
            }
            else
            {
                alert("Your number is not a prime number");
            }
            }
    </script>
    Enter Number to Check:<input type="text" id="num"><input type="button" value="Check" onclick="check();">

Thanks










Related Tutorials/Questions & Answers:
Javascirpt Programing
Javascirpt Programing  write a html page with javascript to check a number is prime or not.   Hi Friend, Try the following code: <script type="text/javascript"> function check(){ var num
Java programing
Java programing   need help wrting this Write a program that has an array of 5 Strings, and determines which ones are palindromes (letter-case does not matter). thanks
Advertisements
socket programing in servlet
socket programing in servlet  give me a example to write socket programing in servlet
programing question
programing question  how do i use loops(for,while) to add components in java   Hi Friend, The below code might help you. import java.awt.*; import javax.swing.*; class TextFieldArray extends JFrame{ JLabel l[]=new
Programing Help - Java Beginners
Programing Help  how to design a filebrowser in java "witout using Swing
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT  I WANT TO KNOW ABOUT THE JAVA SOCKET PROGRAMING FROM BASIC LEVEL AND HOW CAN I WORK ON IT I KNOW THE JAVA PROGRAMING.SO PLEASE HELP ME HOW CAN I DO SOCKET PROGRAMING
Java programing help
Java programing help  Can you help me create this program? Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). As they enter the data, assign
javascript programing error - JSP-Servlet
javascript programing error  hi deepak i m using explorer to run javascript program in this there is no option to check error will u plz tell me the way to check error in explorer as we can check with mozila
java programing problem - Java Beginners
java programing problem  Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion picture Association of America rating , ID Number, and movie title with appropriate
guys,, need help,, in java programing,, arrays
guys,, need help,, in java programing,, arrays  create a program where you will input 10 numbers and arrange it in ascending way using arrays
Tutorials   
Java Spring Hibernate Struts Training How to display button as a link in vaadin? hi change navbar dropdown color in bootstrap How to remove the background color of bootstrap menu bar? How to change color of opened Bootstrap drop down toggle? Setting bootstrap container background color Help school all activities and admision process.. add one row after another date make a webpage HTMl HTMl Source code how to apply globalisation to a world wide asp.net application how to print HTML using javascript or Jquery How to recover from google panda update? How to survive google panda 4.0 update How to find if you have been hit by Panda 4.0 Design a web page using XHTML and JavaScript that does the followings: ffmpeg converting file mp4 to mov JavaScript How to Disable Catch-all Emails on CPanel z-index always on top What is Web hosting Database and HTML web development trainee Uploading files Image Gallery Image Gallery dropdown How to redirect from a HTML page? Easiest method for expiring the css and js headers HTML WITH AJAX VB 6 Read Web Page Header string palindrom using vbscript? html button How to add mod_deflate to apache without recompiling How to use place hoder in IE(version : 8) Html Software Question div align left css Fetching data from excel file on other website and display in interactive graph form where do I find the fix for tree view catalog not expanding and collapsing correctly for roseindia shopping cart 1.1 pass to next page to enter into a particular page only if the username,password and listbox value mtches hi Cricket stadium ticket booking design Need some help creating an order form. HTML div tag HTML div tag

Ads

 
Advertisement null

Ads