What can be optimized in this program, which finds all prime divisors of a natural number N ?
import math def pr(r,n): if n % r == 0: m = int(math.sqrt(r)) g = 2 while g <= m: if r % g == 0: return g += 1 print(r, end=' ') return else: return n = int(input()) pr(2, n) for i in range(3, n + 1, 2): pr(i, n)
Wheel Factorization), I highly recommend watching this chic answer in the English version of SO - MaxU