gpt4 book ai didi

python - 为什么非常大的斐波那契数会产生椭圆形?

转载 作者:行者123 更新时间:2023-12-04 14:53:36 24 4
gpt4 key购买 nike

in_range = int(input("range: "))

fibo_list = []

a = 0
b = 1
count = 0

if in_range < 0:
print("faulty")
elif in_range == 0:
print("faulty")
else:
while count < in_range:
c = a + b
a = b
b = c
count += 1
fibo_list.append(a)


print(fibo_list)

这段代码的范围输入1000时,会产生很多椭圆形状,有些是很难看的。这似乎只发生在斐波那契数列中,而没有其他长数链。为什么是这样? Here is what the ellipses look like

最佳答案

数字之间的空格的“形状”只是将数字与接近终端宽度的宽度(或宽度的倍数)对齐,同时缓慢增加位数的人工制品。斐波那契数列只是碰巧以大致适合看到“椭圆模式”出现的速度增加位数,但任何以类似速度增加位数的模式都会看到这样的模式。也许不在同一个地方,也许曲线更平缓或更陡峭,但相似。

举个简单的例子,打印 1.5 的截断幂从 300 到 600 会产生非常相似的模式:

print([int(1.5 ** i) for i in range(300, 600)])

Power pattern

关于python - 为什么非常大的斐波那契数会产生椭圆形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59149206/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com