Sha256: a011eda77a1f8f03e0c4e444307f2992d756236ba5b0afe4b4377207935eb7e0

Contents?: true

Size: 734 Bytes

Versions: 20

Compression:

Stored size: 734 Bytes

Contents

describe Integer, "#mersenne_prime?" do
  # A000668
  @seq = [3,7,31,127,8191,131071,524287,2147483647,
          2305843009213693951,618970019642690137449562111,
          162259276829213363391578010288127,
          170141183460469231731687303715884105727].to_seq

  @seq.first(6).each do |n|
    it "should return true for Mersenne prime #{n}" do
      n.should be_mersenne_prime
    end
  end

  @seq.invert.first(500).sample(10).each do |n|
    it "should return false for non-Mersenne prime #{n}" do
      n.should_not be_mersenne_prime
    end
  end

  (Prime.first(12).to_a - @seq.to_a).each do |n|
    it "should return false for a prime which isn't Mersenne: #{n}" do
      n.should_not be_mersenne_prime
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

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