Sha256: d2b69c06fb369cfea64226aa890c51b3391b0cd7b54512bc8a70ea5974c779ab

Contents?: true

Size: 771 Bytes

Versions: 5

Compression:

Stored size: 771 Bytes

Contents

# coding: utf-8
# A005185
Q = [1,1,2,3,3,4,5,5,6,6,6,8,8,8,10,9,10,11,11,12,12,
     12,12,16,14,14,16,16,16,16,20,17,17,20,21,19,20,
     22,21,22,23,23,24,24,24,24,24,32,24,25,30,28,26,
     30,30,28,32,30,32,32,32,32,40,33,31,38,35,33,39,
     40,37,38,40,39]

describe Integer, "#q" do
  Q.to_enum.with_index(1).each do |q, n|
    it "returns #{q} for #{n}" do
      n.q.should == q
    end
  end
end

describe Integer, "#q?" do
  Q.each do |n|
    it "returns true for Q-number #{n}" do
      n.should be_q
    end
  end

  # This is unsatisfactory because the abscence of a term in A005185 does not
  # imply the sequence does not contain it...
  Q.to_seq.invert.each do |n|
    it "returns false for non-Q-number #{n}" do
      n.should_not be_q
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
numb-0.186.0 spec/numb/q_spec.rb
numb-0.185.0 spec/numb/q_spec.rb
numb-0.184.0 spec/numb/q_spec.rb
numb-0.181.0 spec/numb/q_spec.rb
numb-0.170.0 spec/numb/q_spec.rb