Spoj problem not accepted

Code link-https://ide.codingblocks.com/s/225229
Problem Link-https://www.spoj.com/problems/NFACTOR/

I am not able to figure out where I’m doing wrong. it shows TLE while submitting. Any body help me get out of it

@imsaurabh
refer to this