Python 找出大于100的整数的最小质因数
def get_prime_factor(num):
for i in range(2, num + 1):
if num % i == 0:
return i
while True:
num = input('请输入一个大于 100 的正整数:')
if not num.isdigit() or int(num) <= 100:
print('输入无效数据,请重新输入')
else:
num = int(num)
break
print(f'{num} 的最小质因数为 {get_prime_factor(num)}')
原文地址: https://www.cveoy.top/t/topic/nE63 著作权归作者所有。请勿转载和采集!