Sha256: 215fd923addc3d2d20409121588fd95ef81d0babbb97c20d549a9f48ea4be7cf

Contents?: true

Size: 848 Bytes

Versions: 20

Compression:

Stored size: 848 Bytes

Contents

describe Integer, "#amicable?" do
  # List from Systematic Computations on Amicable Numbers; Alanen, Ore, &
  # Stemple (http://www.jstor.org/pss/2004169)
  @seq = [220,284,1184,1210,2620,2924,5020,5564,6232,6368,
          10744,10856,12285,14595,17296,18416,63020,76084,
          66928,66992,67095,71145,69615,87633,79750,88730,
          100485,124155,122265,139815,122368,123152,141664,
          153176,142310,168730].to_seq

  @seq.each_slice(2) do |n, m|
    it "should return true for amicable pair #{n}, #{m}" do
      n.amicable?(m).should be_true
    end

    it "should return true for amicable pair #{m}, #{n}" do
      m.amicable?(n).should be_true
    end
  end

  @seq.invert.sample(10).each_slice(2) do |n, m|
    it "should return false for non-amicable pair #{n}, #{m}" do
      n.amicable?(m).should be_false
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
numb-0.186.0 spec/numb/amicable_spec.rb
numb-0.185.0 spec/numb/amicable_spec.rb
numb-0.184.0 spec/numb/amicable_spec.rb
numb-0.181.0 spec/numb/amicable_spec.rb
numb-0.170.0 spec/numb/amicable_spec.rb
numb-0.152.0 spec/numb/amicable_spec.rb
numb-0.138.0 spec/numb/amicable_spec.rb
numb-0.125.0 spec/numb/amicable_spec.rb
numb-0.114.0 spec/numb/amicable_spec.rb
numb-0.111.0 spec/numb/amicable_spec.rb
numb-0.109.0 spec/numb/amicable_spec.rb
numb-0.99.0 spec/numb/amicable_spec.rb
numb-0.96.0 spec/numb/amicable_spec.rb
numb-0.89.0 spec/numb/amicable_spec.rb
numb-0.84.0 spec/amicable_spec.rb
numb-0.77.0 spec/amicable_spec.rb
numb-0.72.1 spec/amicable_spec.rb
numb-0.72.0 spec/amicable_spec.rb
numb-0.68.0 spec/amicable_spec.rb
numb-0.63.0 spec/amicable_spec.rb