prime_big_omega_function_generalized_old.sf 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/ruby
  2. # Author: Daniel "Trizen" Șuteu
  3. # Date: 25 November 2018
  4. # https://github.com/trizen
  5. # Generalization of the prime big omega function `Ω_m(n)`, for `m>=0`:
  6. # Ω_m(n) = n^m * Sum_{p^k|n} k/p^m
  7. # Where the standard prime big omega function `Ω(n)` is equivalent with `Ω_0(n)`.
  8. # See also:
  9. # https://oeis.org/A001222
  10. # https://oeis.org/A022559
  11. # https://oeis.org/A003415
  12. # https://oeis.org/A190121
  13. # https://en.wikipedia.org/wiki/Prime_omega_function
  14. # https://trizenx.blogspot.com/2018/08/interesting-formulas-and-exercises-in.html
  15. func bigomega(n, m) {
  16. n**m * n.factor_exp.sum {|p| p[1] / p[0]**m }
  17. }
  18. say 25.of { bigomega(_, 0) }
  19. say 25.of { bigomega(_, 1) }
  20. say 25.of { bigomega(_, 2) }
  21. say 25.of { bigomega(_, 3) }
  22. say 25.of { bigomega(_, 4) }
  23. say 25.of { bigomega(_, 5) }
  24. __END__
  25. [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]
  26. [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]
  27. [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]
  28. [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]
  29. [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]
  30. [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]