0

Write a program to check if a number is prime in minimum iterations(time)..

hello,i have written a program n I want u to check if it can become more time efficient but reducing the no. of iterations....I have reduced the iterations as to half https://code.sololearn.com/cPa108ugyFbN/?ref=app https://code.sololearn.com/cPa108ugyFbN/?ref=app

8th Oct 2017, 4:42 AM
Abu Shahid
Abu Shahid - avatar
2 odpowiedzi
+ 2
https://code.sololearn.com/cPa108ugyFbN/?ref=app
8th Oct 2017, 6:02 AM
Abu Shahid
Abu Shahid - avatar
+ 7
For even smaller iterations, you may reduce the loop to maximum of Math.sqrt(no); This will also work in the same way, and will be faster.
8th Oct 2017, 5:10 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar