Cody

# Problem 45831. Compute the Bernoulli numbers

Solution 2647523

Submitted on 3 Jul 2020 by Asif Newaz
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))

Bp = 1 Bm = 1

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

Bp = 0.5000 Bm = 0.5000 Bm = -0.5000

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

Bp = 0.1667 Bm = 0.1667

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

Bp = -0.0333 Bm = -0.0333

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

Bp = -0.0333 Bm = -0.0333

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

Bp = -0.2531 Bm = -0.2531

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

Bp = -7.0922 Bm = -7.0922

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

Bp = -529.1242 Bm = -529.1242