lib/numb/mobius.rb in numb-0.170.0 vs lib/numb/mobius.rb in numb-0.181.0
- old
+ new
@@ -1,10 +1,17 @@
# coding: utf-8
class Integer
def mobius
return if self < 1
- ω < Ω ? 0 : (-1)**(Ω)
+ ω < Ω ? 0 : liouville
end
alias :möbius :mobius
alias :μ :mobius
+
+ # TODO: Consider Deléglise and Rivat's "Computing the Summation of the
+ # Mőbius Function", Experimental Mathematics, Vol. 5 (1996), No. 4
+
+ def mertens
+ (1..self).map(&:μ).reduce(:+)
+ end
end