Sha256: 1266ed267437eb7606a9518b635874678ae21258bd2b41f9cf9ca8f251edc678

Contents?: true

Size: 1.13 KB

Versions: 14

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(100).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

14 entries across 14 versions & 1 rubygems

Version Path
numb-0.186.0 spec/numb/dihedral_prime_spec.rb
numb-0.185.0 spec/numb/dihedral_prime_spec.rb
numb-0.184.0 spec/numb/dihedral_prime_spec.rb
numb-0.181.0 spec/numb/dihedral_prime_spec.rb
numb-0.170.0 spec/numb/dihedral_prime_spec.rb
numb-0.152.0 spec/numb/dihedral_prime_spec.rb
numb-0.138.0 spec/numb/dihedral_prime_spec.rb
numb-0.125.0 spec/numb/dihedral_prime_spec.rb
numb-0.114.0 spec/numb/dihedral_prime_spec.rb
numb-0.111.0 spec/numb/dihedral_prime_spec.rb
numb-0.109.0 spec/numb/dihedral_prime_spec.rb
numb-0.99.0 spec/numb/dihedral_prime_spec.rb
numb-0.96.0 spec/numb/dihedral_prime_spec.rb
numb-0.89.0 spec/numb/dihedral_prime_spec.rb