Playing with Numbers why this solution is giving TLE

I don’t know what is wrong with this code
Submission Link: https://www.codechef.com/submit/SJ1
Problem Link: https://www.codechef.com/APRIL19B/problems/SJ1