Skip to content

Instantly share code, notes, and snippets.

@sujyrokimora
Created September 26, 2024 15:59
Show Gist options
  • Select an option

  • Save sujyrokimora/771cd648b4f965d9eb43a733b6eab63c to your computer and use it in GitHub Desktop.

Select an option

Save sujyrokimora/771cd648b4f965d9eb43a733b6eab63c to your computer and use it in GitHub Desktop.
import time
def fibonacci(n):
"""
Calculates fibonnaci sequence numbers recursively
"""
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
def constant(n):
"""
Calculates fibonacci constant
"""
s = 1
c = 0
while s < n:
c = c + (1 / fibonacci(s))
s += 1
print(s, " Im Still Alive! just thinking...")
return c
def main():
n = input("How many numbers?\n")
startTime = time.time()
print( constant( int(n) ) )
endTime = time.time()
print("Done in only ", endTime-startTime, " seconds!")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment