Python Altın Oran Matematik Problemi

Görselleştirme kısmını da siz yaparsınız:

import math
from decimal import Decimal

def fibonacci():
    x = 1
    y = 0
    while True:
        yield x
        x, y = x + y, x

i = fibonacci()

altın_oran = (Decimal(5).sqrt() + 1) / 2

print("Altın oran:", altın_oran)

j, k = next(i), next(i)
while True:
    print(Decimal(k) / Decimal(j))
    j = k
    k = next(i)

1 Beğeni