Discuss / Python / 自定义一个累乘函数

自定义一个累乘函数

Topic source

KKKKKKKEM

#1 Created at ... [Delete] [Delete and Lock User]
在此插入代码

import os def F(a,b): s=a i=0 r=1 while i<=b: r=s*r s=s+1 i=i+1 return r n=int(input("请输入需要累乘的起始数 ")) m=int(input("请输入需要累乘的次数")) p=int(F(n,m)) print(p) os.system("pause")

林林1292

#2 Created at ... [Delete] [Delete and Lock User]

你这个有错误你,你那个I是没用的而且写了之后错的。 修改: def f(a,b): r=1 while a<=b: r=r*a a=a+1 return r

林林1292

#3 Created at ... [Delete] [Delete and Lock User]

不好意思打字的时候多打了一个你字,对不起啊


  • 1

Reply