Sha256: 6af642fa75dcc40898e6df892d228e8b915787647e8ed665e9bf0e5d7ff76ff2

Contents?: true

Size: 899 Bytes

Versions: 36

Compression:

Stored size: 899 Bytes

Contents

describe Integer, "#parasitic?" do
  # http://www.research.att.com/~njas/sequences/A092697
  PARASITIC = [1,105263157894736842,
               1034482758620689655172413793,102564,
               102040816326530612244897959183673469387755,
               1016949152542372881355932203389830508474576271186440677966,
               1014492753623188405797,1012658227848,
               10112359550561797752808988764044943820224719]

  
  it "returns true for parasitic numbers" do
    PARASITIC.each do |number|
      number.should be_parasitic
    end
  end
  
  PARASITIC.each_with_index do |number,n|
    n += 1
    it "returns true for #{n}-parasitic numbers when #{n} is the argument" do
      number.parasitic?(n).should be_true
    end
  end

  it "returns false for non-parasitic numbers" do
    [2, 8, 105263157894736843].each do |number|
      number.should_not be_parasitic
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

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