Sha256: 47fe961a56f3ad11936692beb43f291a84c4154a65d57d3b28acd730cc9203e5

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

describe Integer, "#dihedral_prime?" do
                   # http://www.research.att.com/~njas/sequences/A038136
  DIHEDRAL_PRIME = ([2,11,101,181,1181,1811,18181,108881,110881,
                    118081,120121,121021,121151,150151,151051,151121,
                    180181,180811,181081,188011,188801,1008001,
                    1022201,1028011,1055501,1058011,1082801,1085801,
                    1088081] +
                   # http://www.research.att.com/~njas/sequences/A134996
                   [2,5,11,101,181,1181,1811,18181,108881,110881,
                    118081,120121,121021,121151,150151,151051,151121,
                    180181,180811,181081,188011,188801,1008001,
                    1022201,1028011,1055501,1058011,1082801,1085801,
                    1088081]).uniq

  it "returns true for Dihedral primes" do
    DIHEDRAL_PRIME.each do |number|
      number.should be_dihedral_prime
    end
  end

  it "returns false for non-Dihedral primes" do
    [6,12,4827290].each do |number|
      number.should_not be_dihedral_prime
    end
  end

  it "returns false for primes which aren't Dihedral" do
    [3,17,19].each do |number|
      number.should_not be_dihedral_prime
    end
  end

  it "returns false for non-primes which are Dihedral" do
    [8, 808, 1101].each do |number|
      number.should_not be_dihedral_prime
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
numb-0.21.0 spec/dihedral_prime_spec.rb
numb-0.20.0 spec/dihedral_prime_spec.rb
numb-0.10.0 spec/dihedral_prime_spec.rb
numb-0.9.0 spec/dihedral_prime_spec.rb
numb-0.8.0 spec/dihedral_prime_spec.rb
numb-0.7.0 spec/dihedral_prime_spec.rb
numb-0.6.1 spec/dihedral_prime_spec.rb
numb-0.6.0 spec/dihedral_prime_spec.rb
numb-0.5.0 spec/dihedral_prime_spec.rb
numb-0.4.0 spec/dihedral_prime_spec.rb
numb-0.3.5 spec/dihedral_prime_spec.rb
numb-0.3.4 spec/dihedral_prime_spec.rb
numb-0.3.3 spec/dihedral_prime_spec.rb
numb-0.3.2 spec/dihedral_prime_spec.rb
numb-0.3.1 spec/dihedral_prime_spec.rb
numb-0.3.0 spec/dihedral_prime_spec.rb