试了一个 python fibonacci function
def fibonacci(n):
if n == 0:
return []
elif n == 1:
return [0]
elif n == 2:
return [0, 1]
else:
fib_sequence = [0, 1]
while len(fib_sequence) < n:
next_number = fib_sequence[-1] + fib_sequence[-2]
fib_sequence.append(next_number)
return fib_sequence
蛮不错,返回的snippet很清晰界面我喜欢