Prime factorization - list

前端 未结 17 899
说谎
说谎 2020-11-27 05:06

I am trying to implement a function primeFac() that takes as input a positive integer n and returns a list containing all the numbers in the prime

17条回答
  •  面向向阳花
    2020-11-27 05:23

    The primefac module does factorizations with all the fancy techniques mathematicians have developed over the centuries:

    #!python
    
    import primefac
    import sys
    
    n = int( sys.argv[1] )
    factors = list( primefac.primefac(n) )
    print '\n'.join(map(str, factors))
    

提交回复
热议问题