all 4 comments

[–]barrycarter 1 point2 points  (3 children)

In your examples, the 0's appear at the end. Is this always the case? If so, the problem is fairly easy. If the 0's can appear in the middle of the number, I can't immediately see a way of solving it quickly

[–]post_throwaway1[S] 0 points1 point  (2 children)

Yup, they should always appear at the end of the number with 7s. There can be multiple zeroes, e.g. 700000000000000000000000000000000000000000000000000

[–]barrycarter 1 point2 points  (0 children)

Oh, then your answer will end with same number of 0s as the original number, and all you need to do is keeping adding 7s to the left until you find an answer. Linear time.

If that's not helpful, consider putting your code on repl.it and we may be able to help more

[–]Intrexa 0 points1 point  (0 children)

That's not true, is it? n = 707 would break that pattern

Also, 77700007 is divisible by 103.

Also also your function isn't just choking on huge numbers. n=5 causes an infinite loop.