Sha256: 44b332c49041c8f53b2426305d057aee81f7e1bc9e564f9d93f35f6f4ba94355
Contents?: true
Size: 401 Bytes
Versions: 8
Compression:
Stored size: 401 Bytes
Contents
class Integer def modulo_order(n) return 0 if n < 1 return 1 if self == 2 and n == 1 (1..n.totient).each{|e| return e if (self**e).modulo(n) == 1} 0 end alias :haupt_exponent :modulo_order alias :multiplicative_order :modulo_order # TODO: Add Rational#period for calculating the period of the decimal # expansion of the rational in terms the multiplicative order of 10 end
Version data entries
8 entries across 8 versions & 1 rubygems