answersLogoWhite

0


Best Answer

//some students also asked it with alert dialog box ! I have done it in a HTML page 100% working best of Luck !_Z triplezero here :)

<script type="text/javascript">

var inum, icount=2;

var irem;

inum = prompt("Enter a number.");

if(inum==1)

{

alert("The no. is not prime");

document.write("The no. is not prime");

exit(0);

}

if(inum==2)

{

alert("The no. is prime");

document.write("The no. is prime");

exit(0);

}

do

{

irem=inum%icount;

if(irem==0)

{

alert("The no. is not prime");

document.write("the given no is not prime");

exit(0);

}

icount++;

}

while(icount<=(inum/2));

alert("The no. is prime");

document.write("the given number is prime");

</script>

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can find prime numbers using do while in java script?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you find prime number?

Prime numbers are the numbers that can only be divided by 1 and them selves. As in 13 if you were to factor it using only whole numbers you would see that its factors are only 1 and 13. There for it is prime. While 12 you see that the factors are 1,2,3,4,6,12 meaning that it is not prime.You test several numbers, to see whether they are prime numbers, until you find a prime number.


Why are some numbers prime and some numbers composite?

Prime numbers have only 2 factors while composite numbers have more than 2 factors


How to draw Flowchart to print prime numbers from 1 to 100 using while loop in c language?

c the book mastering c


What two prime numbers are successive?

The two successive prime numbers are 2 and 3. 1 is not a prime number because it has only one factor, while prime numbers have two positive integer factors.


Is there any prime numbers that are square numbers?

No, there are no prime numbers that are also square numbers. Prime numbers are only divisible by 1 and themselves, while square numbers have integer square roots. Since the square root of a prime number is not an integer, a prime number cannot be a square number.


What different between odd number and prime number?

While all prime numbers are odd (except 2), not all odd numbers are prime. 9 for example is an odd number, but you can get it by multiplying 3X3, so it is not prime. Odd numbers are numbers that are not divisible by 2. Prime numbers are numbers that cannot be generated by multiplying 2 whole numbers besides 1 and itself.


Are 232529 is set af all prime numbers?

If you mean: 23 25 and 29 then 23 and 29 are prime numbers while 25 is composite.


Write a shell script to check whether the given input is prime or not?

shell script for check whether the given no is prime or not??echo "input any number:"read nono=`expr $no`i=`expr 2`while [ $i -lt $no ]doif [ `expr $no % $i` -eq 0];thenecho "$no is not a prime no.."break 2fii=`expr $i +1`doneif [ $i -eq $no ];thenecho "$no is a PRIME no..."fi


What type of numbers are 5 7 and 12?

5 and 7 are prime numbers while 12 is a composite number


Are numbers 13-19-29-32 composite numbers?

32 is a composite number while 13, 19 and 29 are prime numbers


Who was the mathematician who suggested a simple method for finding the prime numbers up to a given natural number?

The method of sieving the multiples of prime numbers until only the prime numbers remain, while attributed to Eratosthenes, is originally thought to have been the work of Nicomachus.


Is there an infinite amount of prime numbers?

Yes, as far as we know. It is very hard to prove this wrong or right, but there are prime numbers that have been found with billions of digits.yes, because there are infant composite numbers and prime will pop up Evey one in a while