0
How can I fix my code?
When I enter a number with more than 5 digits, the program terminates. Why does this happen? Is there any way I can fix it? Thank you https://code.sololearn.com/cBV88i20xI70/?ref=app
3 Answers
+ 1
In this case there might be two reasons i could think of,
1. input integer size (must be less then 2^32 as int is in use)
2. computation time (verifying each number from 2 to input number is a huge process)
You can reduce your algorithms computation by half by checking only 2,3,5,7,.. odd numbers alone and data type accordingly maybe long or biginteger
+ 3
you have to minimize the time complexity of your code
0
Sathish Kanna and Samima Hassan Thank you đ