lib/numb/mobius.rb in numb-0.21.0 vs lib/numb/mobius.rb in numb-0.63.0
- old
+ new
@@ -1,11 +1,10 @@
# coding: utf-8
class Integer
def mobius
- case
- when (self < 1) then nil
- when (square_free? and number_of_distinct_prime_factors.even?) then 1
- when (square_free? and number_of_distinct_prime_factors.odd?) then -1
- when (not square_free?) then 0
- end
+ return if self < 1
+ ω < Ω ? 0 : (-1)**(Ω)
end
+
+ alias :möbius :mobius
+ alias :μ :mobius
end