Sha256: 39a1bf25d118b36bb8e161e084f041ce2b31238e1c7acbeb440ad8ebbeec373f

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

describe Integer, "#fibonacci?" do
  # A000045
  FIBONACCI = [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
               1597,2584,4181,6765,10946,17711,28657,46368,75025,
               121393,196418,317811,514229,832040,1346269,
               2178309,3524578,5702887,9227465,14930352,24157817,
               39088169].uniq

  FIBONACCI.each do |n|
    it "returns true for Fibonacci number #{n}" do
      n.should be_fibonacci
    end
  end

  ((0..FIBONACCI.last).to_a - FIBONACCI).shuffle.first(10).each do |n|
    it "returns false for non-Fibonacci number #{n}" do
      n.should_not be_fibonacci
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
numb-0.21.0 spec/fibonacci_spec.rb