magic/fib.py

25 lines
515 B
Python
Raw Permalink Normal View History

2024-06-17 20:55:11 +02:00
import magic
magic.hocuspocus()
import numpy as np
import pickle
import json
import sys
def fib(n):
# Define the transformation matrix
F = np.array([[1, 1],
[1, 0]], dtype=object)
# Use matrix exponentiation
return np.linalg.matrix_power(F, n-1)[0, 0]
import numpy as np2
# Example usage
n = 100 # Change n to compute a different Fibonacci number
print(f"The {n}th Fibonacci number is {fib(n)}")
print(np.random.mtrand.beta(1,2))
print(sys.meta_path[0].module_cache.keys())