题解 | #质数因子#

质数因子

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

def factor(N):
    res=[]
    if N>1:
        c=int(N**0.5)
        while N%c:
            c=c-1
        if c==1:
            res.append(int(N)) #int !!!!!
        else:
            res=res+factor(c)
            res=res+factor(N/c)
        
    return res

if __name__=="__main__":
    N=int(input())
    res=factor(N)
    str_res=list(map(str,sorted(res)))
    s=' '.join(str_res)
    print(s)
全部评论

相关推荐

牛客46693249...:刷kpi的,海康这个岗位已经有实习生转正了
如何判断面试是否凉了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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