n =1# 变量初始化sum=1# 阶乘之和
multiply =1# 每个数的阶乘
n =int(input("计算0~n的阶乘的和 n = "))
temp = n
if n <0:print("非法输入")elif n ==1:print("1的阶乘是1")elif n ==0:print("0的阶乘是1")else:while n >=2:for i inrange(2, n +1):# 计算每个值的阶乘
multiply *= i # 1*2*3....*nsum+= multiply
multiply =1
n = n -1print("0~%d的阶乘之和为%d"%(temp,sum+1))
2. 求最大真约数
a =eval(input())
i = a //2while i >0:if a % i ==0:break
i -=1print(a,"最大真约数为:", i)
a =eval(input())
i =2while i >0:if a % i ==0:break
i +=1print(a,"最大真约数为:",int(a / i))