Sha256: ea831f266170db525ac2c606d5f213cf97187ebaf68bf7ea6d295fdb4aa3a56a

Contents?: true

Size: 482 Bytes

Versions: 2

Compression:

Stored size: 482 Bytes

Contents

require 'prime'

describe "Prime#prime?" do
  it "returns a true value for prime numbers" do
    Prime.prime?(2).should be_true
    Prime.prime?(3).should be_true
    Prime.prime?(2**31-1).should be_true  # 8th Mersenne prime (M8)
  end

  it "returns a false value for composite numbers" do
    Prime.prime?(4).should be_false
    Prime.prime?(15).should be_false
    Prime.prime?(2**32-1).should be_false
    Prime.prime?( (2**17-1)*(2**19-1) ).should be_false  # M6*M7
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysl-prime-2.0.1 spec/prime_spec.rb
rubysl-prime-2.0.0 spec/prime_spec.rb