解题思路:
注意事项:
注意输入为质数时直接输出
参考代码:
from math import sqrt def Isprime(x): for i in range(2,int(sqrt(x))+1): if x % i == 0: return False return True def f(n): temp = n if Isprime(n): print(n) print(1) else: primes = tuple(i for i in range(2,10000) if Isprime(i)) cho = [] for item in primes: while(n % item == 0): cho.append(item) n = n//item if n == 1: break cho.sort() for item in cho: print(item,end=' ') print() print(len(cho)) if __name__ == '__main__': n = int(input()) f(n)
0.0分
0 人评分