BOSTON NUMBERS - Run error

Question: https://hack.codingblocks.com/contests/c/452/1103
My code: https://ide.codingblocks.com/#/s/18697

It gives correct answer for all test cases except 2 and 3. I checked for large values 2,147,483,646. Everything seems fine to me. Please point out my mistake in the code.
TIA!

Hey !!! as the constraints are too large , you cant you use the idea of sieve because sieve will give you the boolean value for nos upto 10^8 but here the given no can be greater than 10^8 .
So use the idea of prime factorisation , it will be the best approach for this question and will not have any run error or tle issue .
if you still have a doubt , have a look at this code you will get this easily .
https://ide.codingblocks.com/#/s/19114