Please look into i wrote this program watching prime factorization video of tutorial from course it still gives TLE in ide and syntax error in coding block software.???
Occuring TLE errors in cb ide and syntax errors in coding block software
Change line 9 to
for(int i=3;i*i<=n;i+=2)
Now it doesn’t throw segmentation fault.
please also tell me the reason behind doing so
I want was going wrong?? with only i??
your i and j variable are int,
Now when i equals n, and j equals n*n, that causes integer overflow and thus the problem.
So restrict i to sqrt(n)