Sha256: b7b2c41ea66ff85d5bd9f61b3c1a54d15ae8f45e1f204701513629ca05c60bd9
Contents?: true
Size: 469 Bytes
Versions: 1
Compression:
Stored size: 469 Bytes
Contents
# coding: utf-8 class Integer def infinitary_divisors pf = Hash[prime_factors.uniq.map{|f| [f, 0]}] bin = divisors.map do |d| prime_divisors = pf.map(&:first) [d, pf.merge(Hash[d.primaries]). values. map{|v| sprintf("%.#{to_s(2).size}b", v)}.join] end bin = Hash[bin] target = bin[self].chars.map.with_index.to_a.select{|a,b| a == '0'}.map(&:last) bin.select{|d,b| target.all?{|i| b[i] == '0'}}.keys.sort end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
numb-0.152.0 | lib/numb/infinitary_divisors.rb |