题解 | 斐波那契数列
斐波那契数列
https://www.nowcoder.com/practice/ee5d403c1172487f8c7915b3c3d924c6
import sys
n = int(input())
if n == 1 or n == 2:
print(1)
sys.exit()
a,b = 1,1
for _ in range(n-2):
c = a+b
b = a
a = c
print(a)
斐波那契数列
https://www.nowcoder.com/practice/ee5d403c1172487f8c7915b3c3d924c6
import sys
n = int(input())
if n == 1 or n == 2:
print(1)
sys.exit()
a,b = 1,1
for _ in range(n-2):
c = a+b
b = a
a = c
print(a)
相关推荐