Sha256: caf53698ed319545ca461b374c3781a028582f303d8229585eb271033577319c
Contents?: true
Size: 920 Bytes
Versions: 4
Compression:
Stored size: 920 Bytes
Contents
# coding: utf-8 describe Integer, "#bernoulli" do # A000367 @numerators = [1, 1, -1, 1, -1, 5, -691, 7, -3617, 43867, -174611, 854513, -236364091, 8553103, -23749461029, 8615841276005, -7709321041217, 2577687858367, -26315271553053477373, 2929993913841559, -261082718496449122051] # A002445 @denominators = [1, 6, 30, 42, 30, 66, 2730, 6, 510, 798, 330, 138, 2730, 6, 870, 14322, 510, 6, 1919190, 6, 13530, 1806, 690, 282, 46410, 66, 1590, 798, 870, 354, 56786730, 6, 510, 64722, 30, 4686, 140100870, 6, 30, 3318, 230010] @seq = @numerators.zip(@denominators).map{|n,d| Rational(n,d)} @seq = ([0.to_r] * @numerators.size).zip(@seq).flatten @seq.shift @seq[1] = -2.reciprocal @seq.each_with_index do |r, n| it "returns #{r} for #{n}" do n.bernoulli.should == r end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
numb-0.186.0 | spec/numb/bernoulli_spec.rb |
numb-0.185.0 | spec/numb/bernoulli_spec.rb |
numb-0.184.0 | spec/numb/bernoulli_spec.rb |
numb-0.181.0 | spec/numb/bernoulli_spec.rb |