Shows TLE in Spoj Problem

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. Any body help me get out of it