Guest User

Untitled

a guest
Oct 13th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. def pfactors(n):
  2.     def find_factor(t):
  3.         (_, n) = t
  4.         if(n == 1):
  5.             return (None, None)
  6.         f = toolz.first(itertools.dropwhile(lambda x: n % x != 0, primes()))
  7.         return (f, n/f)
  8.     return list(toolz.drop(1, map(toolz.first, itertools.takewhile(
  9.         lambda x: x != (None, None), toolz.iterate(find_factor, (0,n))))))
Advertisement
Add Comment
Please, Sign In to add comment