python-裴波那契数列
例如:#一定范围内的斐波那契数列;
def fb(arg1,arg2,stop):
if arg1==0:
print(arg1)
print(arg2)
arg3=arg1+arg2
print(arg3)
if arg3<stop:
fb(arg2,arg3,stop)
fb(0,1,30)
结果:
0
1
1
2
3
5
8
13
21
34
例如:#一定范围内的斐波那契数列;
def fb(arg1,arg2,stop):
if arg1==0:
print(arg1)
print(arg2)
arg3=arg1+arg2
print(arg3)
if arg3<stop:
fb(arg2,arg3,stop)
fb(0,1,30)
结果:
0
1
1
2
3
5
8
13
21
34