Ad
  • Custom User Avatar

    You need not to go from 1 up to n. You should find an optimal stopping point / upper-boundary where you can obtain all the divisors of n.

    Also, doing index in a list is at worst O(N^2) and range within range within range is O(N^3), thus your solution times out.

  • Custom User Avatar

    list(range(n2))

    If you're using a generator expression in a for loop you should not turn it into a list. Making a list of size 2**200 is not a good idea.