python求x阶乘并判断是否是24的倍
2026-03-23 18:46:37
发布于:北京
27阅读
0回复
0点赞
当 n=1: 1! = 1,不能被 24 整除
当 n=2: 2! = 2,不能被 24 整除
当 n=3: 6! = 6,不能被 24 整除
当 n=4: 4! = 24,能被 24 整除
当 n>4: n! 包含 4! 作为因子,所以一定能被 24 整除
n = int(input())
if n >= 4:
print("YES")
else:
print("NO")
# 第二种解法:
#n = int(input())
#print("YES" if n >= 4 else "NO")
全部评论 1






1周前 来自 浙江
0







有帮助,赞一个