质因数分解
#!/usr/bin/env python
#coding:utf-8
import sys
import math
def prime_split(number):
i = 2
sqrt_ = math.sqrt(number)
while i <= sqrt_:
mod_ = number % i
if mod_ == 0:
if number / i != 1:
number /= i
print i
i -= 1
i += 1
print number
if __name__ == "__main__":
if len(sys.argv) != 2:
print "Usage: prime_split.py number"
sys.exit(1)
number = 0
try:
number = int(sys.argv[1])
except Exception, e:
print e.message
prime_split(number)