Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pfactors(n):
- def find_factor(t):
- (_, n) = t
- if(n == 1):
- return (None, None)
- f = toolz.first(itertools.dropwhile(lambda x: n % x != 0, primes()))
- return (f, n/f)
- return list(toolz.drop(1, map(toolz.first, itertools.takewhile(
- lambda x: x != (None, None), toolz.iterate(find_factor, (0,n))))))
Advertisement
Add Comment
Please, Sign In to add comment