Writing High-Performance Python with PyPy (Just-In-Time Compilation)

# Fibonacci sequence with memoization
def fibonacci(n, memo={}):
if n in memo:
return memo[n]
if n <= 2:
return 1
memo[n] = fibonacci(n – 1, memo) + fibonacci(n – 2, memo)
return memo[n]

# Test the Fibonacci function
def main():
n = 10000 # Increase this value for testing
print(fibonacci(n))

if __name__ == “__main__”:
main()

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top