Fibonacci matrix-exponentiation: Difference between revisions
m
→Matrix exponentiation by Ruby's fast exponentiation operator duck-typing applied to Ruby's built-in Integer Class
Line 1,707:
===Matrix exponentiation by Ruby's fast exponentiation operator duck-typing applied to Ruby's built-in Integer Class===
fib_Num=(Matrix[[0,1],[1,1]] ** (n))[0,1]
fib_Str= fib_Num.to_s()
if fib_Str.length <= 21
p ["Fibonattch(#{n})",fib_Str.length.to_s + ' digits' , fib_Str
else
end
{{out}}
<pre>
["Fibonattch(2)", "1 digits", "1"]
["Fibonattch(3)", "1 digits", "2"]
["Fibonattch(4)", "1 digits", "3"]
["Fibonattch(10)", "2 digits", "55"]
[10000, "2090 digits", "33644764876431783266 ... 6607331005994736687", "Took 0.001502226s"]▼
["Fibonattch(100)", "21 digits", "354224848179261915075"]
[65536, "13696 digits", "73199214460290552832 ... 9727019095530746322", "Took 0.003220941s"]▼
▲
▲
["Fibonattch(100000)", "20899 digits", "25974069347221724166 ... 49895374653428746875"]
["Fibonattch(1000000)", "208988 digits", "19532821287077577316 ... 68996526838242546875"]
["Fibonattch(10000000)", "2089877 digits", "11298343782253997603 ... 86998673686380546875"]
Took 1.115647303s
</pre>
|