Commit 126fb14a authored by Martin Mareš's avatar Martin Mareš
Browse files

NumPy: Fibonacci-like

parent 3f15a502
#!/usr/bin/python3
import numpy as np
n = 10
a = -np.eye(n)/2 - np.eye(n, k=1)/2 + np.eye(n, k=2)
a[-2:, -2:] = np.eye(2)
b = np.zeros(n)
b[-2] = 426
b[-1] = 427
x = np.linalg.solve(a, b)
print(x[:2])
#!/usr/bin/python3
a = [256, 512]
for i in range(2, 10):
a.append((a[-1] + a[-2]) / 2)
print(a)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment