Sha256: 403cc2f2ade37dc2e3667968aa4f8a3d5b8397aa2d85df6e76b7036d84122341
Contents?: true
Size: 1.87 KB
Versions: 7
Compression:
Stored size: 1.87 KB
Contents
describe Integer, "#n_step_fibonacci" do @seq = { # A000045 2 => [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987, 1597,2584,4181,6765,10946,17711,28657,46368,75025, 121393,196418,317811,514229,832040,1346269, 2178309,3524578,5702887,9227465,14930352,24157817, 39088169], # A000073 3 => [0,0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705, 3136,5768,10609,19513,35890,66012,121415,223317, 410744,755476,1389537,2555757,4700770,8646064, 15902591,29249425,53798080,98950096,181997601, 334745777], # A000078 4 => [0,0,0,1,1,2,4,8,15,29,56,108,208,401,773,1490, 2872,5536,10671,20569,39648,76424,147312,283953, 547337,1055026,2033628,3919944,7555935,14564533, 28074040,54114452,104308960,201061985,387559437, 747044834], # A001591 5 => [0,0,0,0,1,1,2,4,8,16,31,61,120,236,464,912,1793, 3525,6930,13624,26784,52656,103519,203513,400096, 786568,1546352,3040048,5976577,11749641,23099186, 45411804,89277256,175514464,345052351,678355061, 1333610936], # A001592 6 => [0,0,0,0,0,1,1,2,4,8,16,32,63,125,248,492,976, 1936,3840,7617,15109,29970,59448,117920,233904, 463968,920319,1825529,3621088,7182728,14247536, 28261168,56058368,111196417,220567305,437513522, 867844316], # A122189 7 => [0,0,0,0,0,0,1,1,2,4,8,16,32,64,127,253,504,1004, 2000,3984,7936,15808,31489,62725,124946,248888, 495776,987568,1967200,3918592,7805695,15548665, 30972384,61695880,122895984,244804400,487641600, 971364608], } @seq.each_pair do |n, ks| ks.first(10 + n).each_with_index do |x, k| it "returns #{x} for the #{k}#{k.ordinal} #{n}-step Fibonacci number" do k.n_step_fibonacci(n).should == x end end end end
Version data entries
7 entries across 7 versions & 1 rubygems