Sha256: 842816a883db15f751970466eda6f9c3685e6caddbb8eb697c15a03e73030db3

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

describe Integer, "#dihedral_prime?" do
          # A038136
  @seq = ([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] +
          # 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.to_seq

  @seq.each do |n|
    it "returns true for Dihedral prime #{n}" do
      n.should be_dihedral_prime
    end
  end

  @seq.invert.sample(10).each do |n|
    it "returns false for non-Dihedral-prime #{n}" do
      n.should_not be_dihedral_prime
    end
  end

  [3, 7, 9].each do |n|
    it "returns false for #{n} which is a prime but not Dihedral" do
      n.should_not be_dihedral_prime
    end
  end

  [8, 808, 1101].each do |n|
    it "returns false for #{n} which is Dihedral and composite" do
      n.should_not be_dihedral_prime
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
numb-0.84.0 spec/dihedral_prime_spec.rb
numb-0.77.0 spec/dihedral_prime_spec.rb
numb-0.72.1 spec/dihedral_prime_spec.rb
numb-0.72.0 spec/dihedral_prime_spec.rb
numb-0.68.0 spec/dihedral_prime_spec.rb
numb-0.63.0 spec/dihedral_prime_spec.rb