0

output shows exceution timed out??

6th May 2020, 4:31 PM
Harithra Shanmugam
4 Respostas
+ 3
Hello Harithra Shanmugam I think you should rework your whole code (there are also many wrong brackets). Use a for loop: It starts at 2 and ends at Math.sqrt(yourNumber) Now you only need to check if your number is divisible by i. If yes -> not a prime If not -> prime You only need to be careful with 2 (it is prime and divisble by 2).
6th May 2020, 5:22 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
Your condition says 'while a==0'. You never change it in the loop, so it runs forever.
6th May 2020, 4:38 PM
HonFu
HonFu - avatar
0
Link the code pls
6th May 2020, 4:32 PM
Abhay
Abhay - avatar
6th May 2020, 4:33 PM
Harithra Shanmugam