纳兰小寒
发表于 2018-2-25 13:39:54
l =
for i in range(0,100):
l.append(l[-1]+l[-2])
print(l)
强硬态度
发表于 2018-2-26 21:06:37
#这个我看懂了
s=#数列开始为0,1
for i in range(30):#取30个数
s.append(s[-1]+s[-2])#列表中倒数第一,二个数的和生成下一个数
print(s)#打印列表S
lemon123
发表于 2018-2-27 16:55:00
def abc():
a,b=1,1
while True:
a,b=b,a+b
yield a
for n in abc():
print n
raw_input()
victor.xu
发表于 2018-3-2 12:58:37
def fib(n):
if n == 1 or n == 2:
return 1
else:
return fib(n-1) + fib(n-2)
n = int(input('请输入自然数:\n'))
print(fib(n))
benzhj
发表于 2018-3-8 11:52:47
l =
x = int (input ('请输入一个数:'))
if x == 0:
print (0)
elif x == 1:
print (0,1)
else :
for i in range(0,x-2):
l.append(l[-1] + l[-2])
print (l)
print ("第{}个数是:{}".format(x,l[-1]))
zxw920506
发表于 2018-3-22 09:23:36
list1 =
for i in range(2,100):
list1.append(list1 + list1)
print(list1)
zlfy1982
发表于 2018-3-22 15:49:10
def fab(n):
if n == 1 :
return 0
elif n ==2 :
return 1
else:
return fab(n-1)+fab(n-2)
for i in range(1,10):
fab(i)
print(fab(i))
tsembrace
发表于 2018-4-7 11:31:26
#斐波那契数列
def gfib():
a,b=0,1
yield b
while True:
a,b=b,a+b
yield b
n=int(input('请输入需要打印斐波拉契数列的长度:\n'))
myfib=gfib()
while n:
print(next(myfib),end=' ')
n=n-1
天天学习$
发表于 2018-4-23 18:56:20
def rabbit():
i = int(input('请输入第几个数:'))
rabbit =
x = 0
y = 1
while(i -2) > 0:
now_rabbit = rabbit + rabbit
rabbit.append(now_rabbit)
x += 1
y += 1
i -= 1
print(rabbit[(len(rabbit) - 1)])
小庆子
发表于 2018-4-28 18:36:43
本帖最后由 小庆子 于 2018-4-28 18:39 编辑
time = int(input('你想要求数列数字的数目是多少:'))
Fibonacci =
while len(Fibonacci) < time :
a = Fibonacci[-1] + Fibonacci[-2]
Fibonacci.append(a)
print(Fibonacci)
萧丹夜
发表于 2018-5-8 20:10:38
k = 2
a = []
a.append(0)
a.append(1)
while k < 100:
a.append(a[-1]+a[-2])
k += 1
print(a)
BISHIQIUQIUI
发表于 2018-5-9 16:07:01
#斐波那契数列
x=0
y=1
n=int(input("arr="))
for i in range (n):
print(x,end=",")
x,y=y,x+y
张大哈
发表于 2018-6-7 16:11:13
L=
for i in range(2,100):
L.append(L+L)
print(L)
我个猪
发表于 2018-6-14 01:33:45
list =
for i in range(50):
list = list + list
list.append(list)
print(list)
892427369
发表于 2018-7-17 13:05:02
a = 0
b = 1
c = 1
print(a,end="、")
print(b,end="、")
print(c,end="")
while True:
a = b
b = c
c = a + b
print("、",c,sep="",end="")
Milo_Ye
发表于 2018-7-18 10:36:44
i = 0
j = 1
k = 0
while k < 100:
k = i+j
i = j
j = k
print(k)
DavidCowboy
发表于 2018-8-1 12:45:53
a = 0
b = 1
i = 0
for i in range(20):
c = a
a = b
b = b + c
print(b)
songmenghua
发表于 2018-8-18 22:06:10
def fs():
L =
n = int(raw_input('FS序列前多少个数:'))
for i in range(2, n):
a = L + L
L.append(a)
print L
一步半个脚印
发表于 2018-8-22 14:28:13
list=
x=int(input('Please input you aimed output number of Fibonacci sequence:'))
if x == 1 or x==2 :
print('The first and secomd number of Fibonacci sequence are :',list)
else:
for i in range(0,x-2):
sum = list+list
list.append(sum)
print(list)
就是这么skr!!!!!
acgods
发表于 2018-8-23 17:09:04
sequence = []
def fib(num):
if num <= 1:
return num
else:
return fib(num-1) + fib(num-2)
for i in range(10):
sequence.append(fib(i))
print(sequence)