题解 | #质数因子#

质数因子

https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607?tpId=37&tqId=21229&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=

import math

while True:
    try:
        n = int(input())
        for i in range(2, int(math.sqrt(n)) + 1):
            while n % i == 0:
                if n % i == 0:
                    print(i, end=' ')
                    n /= i
        if n > 1:
            print(int(n))
    except:
        break

Python刷华为机考题 文章被收录于专栏

无聊刷刷!

全部评论

相关推荐

码农索隆:以下是我以我微薄的认知提供的建议: 1.考个教师资格证,去当体育考试。 2.去健身房当健身教练(因为在我印象里面体育生身材都不错)。
点赞 评论 收藏
分享
递归到脑子变傻:杭州还有上位机用VB的,实在没绷住
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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