-
Notifications
You must be signed in to change notification settings - Fork 0
/
fibonacci_polynomial_numbers.sf
34 lines (29 loc) · 1.63 KB
/
fibonacci_polynomial_numbers.sf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/ruby
# Daniel "Trizen" Șuteu
# Date: 31 May 2017
# https://github.com/trizen
# Closed-form generation of Fibonacci polynomial numbers.
func fibonacci(t, n) {
var a = sqrt(n**2 + 4)
var b = (a + sqrt(a**2 - 4))/2
((b**t - (-b)**(-t)) / a)
}
(1..15).each { |n|
say "F(#{'%2d' % n}, n) = [ #{ 10.of { fibonacci(n, _) }.join(', ') }, ... ]"
}
__END__
F( 1, n) = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ... ]
F( 2, n) = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... ]
F( 3, n) = [ 1, 2, 5, 10, 17, 26, 37, 50, 65, 82, ... ]
F( 4, n) = [ 0, 3, 12, 33, 72, 135, 228, 357, 528, 747, ... ]
F( 5, n) = [ 1, 5, 29, 109, 305, 701, 1405, 2549, 4289, 6805, ... ]
F( 6, n) = [ 0, 8, 70, 360, 1292, 3640, 8658, 18200, 34840, 61992, ... ]
F( 7, n) = [ 1, 13, 169, 1189, 5473, 18901, 53353, 129949, 283009, 564733, ... ]
F( 8, n) = [ 0, 21, 408, 3927, 23184, 98145, 328776, 927843, 2298912, 5144589, ... ]
F( 9, n) = [ 1, 34, 985, 12970, 98209, 509626, 2026009, 6624850, 18674305, 46866034, ... ]
F(10, n) = [ 0, 55, 2378, 42837, 416020, 2646275, 12484830, 47301793, 151693352, 426938895, ... ]
F(11, n) = [ 1, 89, 5741, 141481, 1762289, 13741001, 76934989, 337737401, 1232221121, 3889316089, ... ]
F(12, n) = [ 0, 144, 13860, 467280, 7465176, 71351280, 474094764, 2411463600, 10009462320, 35430783696, ... ]
F(13, n) = [ 1, 233, 33461, 1543321, 31622993, 370497401, 2921503573, 17217982601, 81307919681, 322766369353, ... ]
F(14, n) = [ 0, 377, 80782, 5097243, 133957148, 1923838285, 18003116202, 122937341807, 660472819768, 2940328107873, ... ]
F(15, n) = [ 1, 610, 195025, 16835050, 567451585, 9989688826, 110940200785, 877779375250, 5365090477825, 26785719340210, ... ]