题解 | #质数因子#

质数因子

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

a = int(input())
# b = int(a/2)
L = []
def cul(a,L):
    if a==1:
        return
    for i in range(2,int(a**(1/2))+1):
        if a % i == 0 and a != 1:
            L.append(i)
            next =int( a / i)
            _,a = cul(next,L)
            break
    return L,a
L,b = cul(a,L)
if b != 1:
    L.append(b)
print(" ".join(str(i) for i in L))

疯狂刷题专栏 文章被收录于专栏

只要刷不死,就往死里刷-

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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