-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprime_big_omega_function_generalized.sf
45 lines (35 loc) · 1.49 KB
/
prime_big_omega_function_generalized.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
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/ruby
# Author: Daniel "Trizen" Șuteu
# Date: 27 November 2018
# https://github.com/trizen
# Generalization of the prime big omega function `Ω_m(n)`, for `m>=0`:
#
# Ω_m(n) = Sum_{p^k|n} Sum_{j=1..k} n^m / p^(j*m)
# = Sum_{p^k|n} n^m * (p^(m*k) - 1) / (p^m - 1) / p^(m*k)
#
# Where the standard prime big omega function `Ω(n)` is equivalent with `Ω_0(n)`.
# See also:
# https://oeis.org/A001222
# https://oeis.org/A095112
# https://en.wikipedia.org/wiki/Prime_omega_function
# https://trizenx.blogspot.com/2018/08/interesting-formulas-and-exercises-in.html
func bigomega(n, m) {
var total = 0
for p,k in (n.factor_exp) {
total += sum(1..k, {|j| n**m / p**(j*m) })
}
return total
}
say 25.of { bigomega(_, 0) }
say 25.of { bigomega(_, 1) }
say 25.of { bigomega(_, 2) }
say 25.of { bigomega(_, 3) }
say 25.of { bigomega(_, 4) }
say 25.of { bigomega(_, 5) }
__END__
[0, 0, 1, 1, 2, 1, 2, 1, 3, 2, 2, 1, 3, 1, 2, 2, 4, 1, 3, 1, 3, 2, 2, 1, 4]
[0, 0, 1, 1, 3, 1, 5, 1, 7, 4, 7, 1, 13, 1, 9, 8, 15, 1, 17, 1, 19, 10, 13, 1, 29]
[0, 0, 1, 1, 5, 1, 13, 1, 21, 10, 29, 1, 61, 1, 53, 34, 85, 1, 121, 1, 141, 58, 125, 1, 253]
[0, 0, 1, 1, 9, 1, 35, 1, 73, 28, 133, 1, 307, 1, 351, 152, 585, 1, 953, 1, 1189, 370, 1339, 1, 2483]
[0, 0, 1, 1, 17, 1, 97, 1, 273, 82, 641, 1, 1633, 1, 2417, 706, 4369, 1, 7873, 1, 10881, 2482, 14657, 1, 26209]
[0, 0, 1, 1, 33, 1, 275, 1, 1057, 244, 3157, 1, 9043, 1, 16839, 3368, 33825, 1, 66857, 1, 104149, 17050, 161083, 1, 289619]