figurate_numbers 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ module Utils
2
+ extend self
3
+
4
+ def factorial_iter(num)
5
+ t = 1
6
+ (1..num).each do |i|
7
+ t = t * i
8
+ end
9
+ t
10
+ end
11
+
12
+ def binomial_coefficient(n, k)
13
+ factorial_iter(n) / (factorial_iter(k) * factorial_iter(n - k))
14
+ end
15
+
16
+ def rising_factorial(n, k)
17
+ t = 1
18
+ (n..(n + k - 1)).each do |i|
19
+ t *= i
20
+ end
21
+ t
22
+ end
23
+
24
+ def pseudo_rising_factorial(n, k)
25
+ t = 1
26
+ (n..(n + k - 2)).each do |i|
27
+ t *= i
28
+ end
29
+ t
30
+ end
31
+
32
+ def pseudo_pochhammer_function(n, k)
33
+ (n..(n + k - 2)).reduce(:*)
34
+ end
35
+
36
+ end
37
+
38
+
@@ -0,0 +1,3 @@
1
+ module FigurateNumbers
2
+ VERSION="1.4.0"
3
+ end