Playing with Numbers why this solution is giving TLE

I don’t know what is wrong with this code
Submission Link: CodeChef: Practical coding for everyone
Problem Link: CodeChef: Practical coding for everyone