题解 | #质数因子#

质数因子

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

import math
input_n = int(input())
for i in range(2,int(math.sqrt(input_n)+1)):
    while  input_n % i == 0:
        input_n = input_n//i
        print(i,end = ' ')
if input_n > 2:
    print(input_n)

感觉 for 循环内嵌套 while是难点 
知识点 print内加 end=' ' 不换行输出
            // 取商的整数部分
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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