why was I getting time error in this question

https://www.codechef.com/viewsolution/55193004

N is 10 ^9, which means O(N) will be TLE if you loop from 0 to n, accepted ones will be O(1) and O(logN), I did an optimized O(logN) findAllfactors of n - 1 Solution: 55186177 | CodeChef

got it.
thanks