Sha256: 2d1096377d440c1ce77b6d58db9374d0450a4f61958bc24b6acde35705c4b49a
Contents?: true
Size: 803 Bytes
Versions: 5
Compression:
Stored size: 803 Bytes
Contents
# coding: utf-8 class Integer def multiamicable?(m, a, b) return false unless m != self and m < self and a.positive? and b.positive? m.σ - m == a*self and σ - self == b*m end def amicable?(other) n, m = [self, other].minmax m.multiamicable?(n, 1, 1) end def augmented_amicable?(n) m = self [m.σ, n.σ].all?{|sigma| sigma == m + n - 1} end def betrothed?(m) σ == m.σ and consecutive?(σ - m) end alias :quasi_amicable? :betrothed? alias :reduced_amicable? :betrothed? def breeder?(b) a = self x = (a.σ - a).fdiv(b) abx = a + (b*x) (abx == a.σ) and (abx == b.σ * (x + 1)) end def unitary_amicable?(n) [n + self, sum_of_unitary_divisors].all? do |other| other == n.sum_of_unitary_divisors end end end
Version data entries
5 entries across 5 versions & 1 rubygems