Skip to content

Instantly share code, notes, and snippets.

@shekkbuilder
Created May 30, 2017 05:49
Show Gist options
  • Save shekkbuilder/398454acbfaa886ddcd855d5d5b6e758 to your computer and use it in GitHub Desktop.
Save shekkbuilder/398454acbfaa886ddcd855d5d5b6e758 to your computer and use it in GitHub Desktop.
Print prime factors of number.
import sys
def factors(n): return ([x]+factors(n/x) for x in xrange(2,n+1) if n%x==0).next() if n>1 else []
num=int(sys.argv[1])
print factors(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment