-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprime_big_omega_function_generalized_old.sf
37 lines (30 loc) · 1.39 KB
/
prime_big_omega_function_generalized_old.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
#!/usr/bin/ruby
# Author: Daniel "Trizen" Șuteu
# Date: 25 November 2018
# https://github.com/trizen
# Generalization of the prime big omega function `Ω_m(n)`, for `m>=0`:
# Ω_m(n) = n^m * Sum_{p^k|n} k/p^m
# Where the standard prime big omega function `Ω(n)` is equivalent with `Ω_0(n)`.
# See also:
# https://oeis.org/A001222
# https://oeis.org/A022559
# https://oeis.org/A003415
# https://oeis.org/A190121
# https://en.wikipedia.org/wiki/Prime_omega_function
# https://trizenx.blogspot.com/2018/08/interesting-formulas-and-exercises-in.html
func bigomega(n, m) {
n**m * n.factor_exp.sum {|p| p[1] / p[0]**m }
}
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, 4, 1, 5, 1, 12, 6, 7, 1, 16, 1, 9, 8, 32, 1, 21, 1, 24, 10, 13, 1, 44]
[0, 0, 1, 1, 8, 1, 13, 1, 48, 18, 29, 1, 88, 1, 53, 34, 256, 1, 153, 1, 216, 58, 125, 1, 496]
[0, 0, 1, 1, 16, 1, 35, 1, 192, 54, 133, 1, 496, 1, 351, 152, 2048, 1, 1161, 1, 2064, 370, 1339, 1, 5696]
[0, 0, 1, 1, 32, 1, 97, 1, 768, 162, 641, 1, 2848, 1, 2417, 706, 16384, 1, 9153, 1, 20256, 2482, 14657, 1, 66304]
[0, 0, 1, 1, 64, 1, 275, 1, 3072, 486, 3157, 1, 16576, 1, 16839, 3368, 131072, 1, 74601, 1, 201024, 17050, 161083, 1, 779264]