I too know of using continue and break statements let take a example of prime number 555643 to check it is prime are not loop sh | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

I too know of using continue and break statements let take a example of prime number 555643 to check it is prime are not loop sh

I too know of using continue and break statements let take a example of prime number 555643 to check it is prime are not loop should be used efficienctly

28th Apr 2017, 4:08 PM
tharun
tharun - avatar
1 Answer
+ 9
if the number is divisible, break the loop. for(int i = 3; i <= Math.sqrt(555643); i+=2) if(555643 % i == 0) break; // is prime, lets get outa here
28th Apr 2017, 6:19 PM
Rrestoring faith
Rrestoring faith - avatar