answersLogoWhite

0

//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

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga

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
Continue Learning about Math & Arithmetic

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.


What are similarities between prime numbers and prime colors?

Prime numbers and prime colors are both fundamental in their respective fields. Prime numbers are integers greater than 1 that are only divisible by 1 and themselves, while prime colors are pure and cannot be created by mixing other colors. Both prime numbers and prime colors are considered basic building blocks in mathematics and color theory, respectively. Additionally, just as prime numbers play a crucial role in number theory, prime colors are essential in fields such as art, design, and psychology.