题解 | #质数因子#

质数因子

http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607

python3

num = int(input())
def getZhi(x):
    isZhi = 1
    for i in range(2,int(x**0.5+2)):
        if x%i == 0:
            isZhi = 0
            print(i,end=' ')
            getZhi(x//i)
            break
    if isZhi == 1:
        print(x,end=' ')
getZhi(num)
全部评论

相关推荐

评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务