Рет қаралды 16,095
PyMath Playlist: • PyMath
Today we compute an absolute Matrix Troll. We are going to compute ((1,0,1),(1,1,0),(0,1,1))^25 which actually has a beautiful cyclic behavious of order 3 after decomposing it into an addition of Matrices and using the binomial Theorem. After that we compute the desired Entries in Python by implementing a factorial and n choose k using recursion. Enjoy :)
The Code:
def fac(x):
f = 1
for i in range(1, x+1):
f *= i
return f
def nCk(n,k):
choose = int(fac(n)/(fac(n-k)*fac(k)))
return choose
def Sum(s, l, u):
S = 0
i = l
while i (less or equal) u:
S += nCk(u, i)
i += s
return S
step = int(input('Step Size?: '))
lower = int(input('Lower Bound?: '))
upper = int(input('Upper Bound?: '))
print('Sum is: ', Sum(step, lower, upper))
Help me create more free content! =)
/ mathable
Merch :v - papaflammy.myt...
www.amazon.com...
shop.spreadshi...
Become a Member of the Flammily! :0 / @papaflammy69
2nd Channel: / @npcooking69
--------------------------------------------------------------------------------
Wanna send me some stuff? lel:
Postfach 11 15
06731 Bitterfeld-Wolfen
Saxony-Anhalt
Germany
--------------------------------------------------------------------------------
My Website: papaflammy.eng...
Instagram: / uncomfortably_cursed_m...
Flammy's subreddit: / flammybois
Twitter: / flammablemaths
Facebook: / flammablemaths
Got some time to spare? Make sure to add captions to my videos! =) www.youtube.com...
Want to know more about me? Watch my QnA! =D • Question and Answer Ti...