Fibonacci matrix-exponentiation: Difference between revisions

Content deleted Content added
RubyFun (talk | contribs)
RubyFun (talk | contribs)
Line 1,706:
=={{header|Ruby}}==
===Matrix exponentiation by Ruby's fast exponentiation operator duck-typing applied to Ruby's built-in Integer Class===
<pre>
 
require 'matrix'
start_time = Time.now
[0,1,2,3,4,10,100,256, 1_000, 1024, 10_000, 2 ** 16, 100_000, 1_000_000,10_000_000 ].each {|n|
##
fib_Num=(Matrix[[0,1],[1,1]] ** (n))[0,1] ## Matrix exponentiation
##
fib_Str= fib_Num.to_s()
if fib_Str.length <= 21
Line 1,719 ⟶ 1,721:
}
puts "Took #{Time.now - start_time}s"
 
</pre>
 
{{out}}