exponential_sigma.sf 680 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/ruby
  2. # Sum of exponential divisors (or e-divisors) of n.
  3. # Multiplicative with:
  4. # a(p^e, k) = Sum_{d|e} p^(d*k)
  5. # See also:
  6. # https://oeis.org/A051377
  7. func exponential_sigma(n, k=1) {
  8. n.factor_prod {|p,e|
  9. e.divisors.sum {|d| p**(d*k) }
  10. }
  11. }
  12. say map(1..20, {exponential_sigma(_, 1)})
  13. say map(1..20, {exponential_sigma(_, 2)})
  14. say map(1..20, {exponential_sigma(_, 3)})
  15. __END__
  16. [1, 2, 3, 6, 5, 6, 7, 10, 12, 10, 11, 18, 13, 14, 15, 22, 17, 24, 19, 30]
  17. [1, 4, 9, 20, 25, 36, 49, 68, 90, 100, 121, 180, 169, 196, 225, 276, 289, 360, 361, 500]
  18. [1, 8, 27, 72, 125, 216, 343, 520, 756, 1000, 1331, 1944, 2197, 2744, 3375, 4168, 4913, 6048, 6859, 9000]