Boston numbers (Challenges, maths)

Unable to detect the error in my code.

Hey @aman_ishan it is possible for a number to have prime factors greater than sqrt(n) for example in 22, 11 is its prime factor, so instead of checking prime factors till sqrt(n) check them till n itself.

Also as soon as you take n as input please check if n is prime, if it is print 0 otherwise move ahead.

Still not able to do…

In line 48 you need to replace p with n
Here is the code with the same done https://ide.codingblocks.com/s/179393

Thank you sir for your response. It worked.