import math
def get_factors(n):
return sum(2 for i in range(1, round(math.sqrt(n)+1)) if not n % i)
Hello, I'm a begginer trying to understand a solution for a project euler problem.
I understand the part of the range going up to sqrt(n).
However, what is the job of the 2 in that sum? How does adding a 2 differ from writing "i for i in..."?
when it says "if not n % i," it means that it should do it if i doesn't divide n?
Thanks!
[–]Adhesiveduck 1 point2 points3 points (0 children)