Sha256: 03d0b55037040fcf0803de3ee84b5a8f43ba9aa3a2ab302f7ca2363e5d09c859
Contents?: true
Size: 515 Bytes
Versions: 31
Compression:
Stored size: 515 Bytes
Contents
# coding: utf-8 class Integer # Implementation of Stewart, B. M. (1954), "Sums of distinct divisors", # American Journal of Mathematics 76: 779–785, doi:10.2307/2372651, # MR0064800 def practical? sum = 1 k = 2 n = self while (n >= k) s = 1 u = 0 while (n % k == 0) n = n/k s = s * k + 1 u += 1 end unless (u == 0) return false if (k > sum + 1) sum *= s end k += (k == 2) ? 1 : 2 end true end end
Version data entries
31 entries across 31 versions & 1 rubygems