Sha256: 8411b23c7311138fa520849286ad86276749cdddc7862bbc37ec3576099ce9ff

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

# coding: utf-8
describe Integer, "#persistent?" do

  @seq = {
    # A051264
    1 => [1023456798,1023456897,1023456978,1023456987,
          1023457698,1023457896,1023457968,1023457986,
          1023458697,1023458796,1023458967,1023458976,
          1023459678,1023459687,1023459768,1023459786,
          1023459867,1023459876],
    # A051018      
    2 => [1023456789,1023456879,1023457689,1023457869,
          1023458679,1023458769,1023465789,1023465879,
          1023467589,1023467859,1023468579,1023468759,
          1023475689,1023475869,1023476589,1023476859,
          1023478569,1023478659],
    # A051019      
    3 => [1052674893,1052687493,1052746893,1052748693,
          1052867493,1052874693,1053267489,1053268749,
          1053274869,1053286749,1053287469,1065273489,
          1065287349,1067285493,1067328549,1068547293,
          1068547329,1068549273],
    # A051020      
    4 => [1253094867,1267085493,1268547309,1269085473,
          1273085469,1308547269,1308549267,1326854907,
          1327068549,1328746905,1450687329,1450732869,
          1450867293,1450928673,1452687309,1452690873,
          1452730869,1453087269],
  }

  @seq.each do |n,ks|
    ks.each do |k|
      it "returns true for #{n}-persistent number #{k}" do
        k.should be_persistent(n)
      end
    end

    ks.to_seq.invert.sample(20).each do |k|
      it "returns false for non-#{n}-persistent number #{k}" do
        k.should_not be_persistent(n)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
numb-0.186.0 spec/numb/persistent_spec.rb
numb-0.185.0 spec/numb/persistent_spec.rb
numb-0.184.0 spec/numb/persistent_spec.rb
numb-0.181.0 spec/numb/persistent_spec.rb
numb-0.170.0 spec/numb/persistent_spec.rb
numb-0.152.0 spec/numb/persistent_spec.rb