# HG changeset patch # User Dominic Cleal # Date 1228136877 0 # Node ID 76155198a9e28c7bb18df6700a988584a7d83ea6 # Parent 0aeacd17f4938179b67e25b0c951195a25a6f178 Adding factorisation library diff -r 0aeacd17f493 -r 76155198a9e2 factors.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/factors.py Mon Dec 01 13:07:57 2008 +0000 @@ -0,0 +1,14 @@ +import primes + +def find(f): + factors = [] + t = 1 + s = primes.sieve() + for p in s.sieve(): + if f % p == 0: + if not p in factors: + factors.append(p) + t *= p + if t == f: + return factors +