Skip to content

Instantly share code, notes, and snippets.

@Ph0enixKM
Last active January 28, 2019 06:16
Show Gist options
  • Save Ph0enixKM/5d606447f6380673d5da613d9dd65107 to your computer and use it in GitHub Desktop.
Save Ph0enixKM/5d606447f6380673d5da613d9dd65107 to your computer and use it in GitHub Desktop.
length = float(input("Insert length of a segment: "))
acc = int(input("Insert accuracy: "))
smallest = float("0." + "0" * acc + "1")
a = length
b = smallest
while round(a / b, acc) != round((a + b) / a, acc):
a -= smallest
b += smallest
print("---")
print("Golden Ratio: " + str(a / b))
print("Segment a: " + str(a))
print("Segment b: " + str(b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment