Cody

Problem 45831. Compute the Bernoulli numbers

Solution 2510702

Submitted on 10 Jun 2020 by ChrisR
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
m = 0; B_correct = [1, 1]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))

2   Pass
m = 1; B_correct = [0.5, -0.5]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))

3   Pass
m = 2; B_correct = [0.1666667, 0.1666667]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))

4   Pass
m = 4; B_correct = [-0.0333333 -0.0333333]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))

5   Pass
m = 8; B_correct = [-0.0333333 -0.0333333]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))

6   Pass
m = 12; B_correct = [-0.2531136, -0.2531136]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))

7   Pass
m = 16; B_correct = [-7.0921569, -7.0921569]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))

8   Pass
m = 20; B_correct = [-529.1242424, -529.1242424]; [Bp,Bm] = BernoulliNumber(m); assert(isequal([Bp,Bm],B_correct))