Aug-15-2020, 11:52 AM
Dear all,
I am in the process of learning python and going through the mod operator.
I am having a hard time understanding what is the meaning of k in the following. Why does it decide k == 2?
Highly appreciate your support.
I am in the process of learning python and going through the mod operator.
I am having a hard time understanding what is the meaning of k in the following. Why does it decide k == 2?
Highly appreciate your support.
def smallest_factor(n): for k in range(2, n): if n % k == 0: return k ans = smallest_factor(33) if ans == 3: print("CORRECT: 3 is the smallest factor of 33") else: print("WRONG: 3 is the smallest factor of 33 but the code returned", ans)