Here is the Python code for a function which factors its argument into primes. It an be called at the commandnd
% python ev "factor(123456789)"
def factor(n): """Return list of prime factors of n. Method = trial division.""" d = 2 factors = [ ] while n % 2 == 0: factors.append(2) n = n//2 d = 3 while n > 1 and d*d <= n: if n % d == 0: factors.append(d) n = n//d else: d = d + 2 if n > 1: factors.append(n) return factors
zipTimer: an iPod/iPhone app for pacing piano practice, cooking, workouts, you name it.