Cody

# Problem 42823. Babylonian method

Solution 881424

Submitted on 25 Apr 2016 by Zikobrelli
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
a=1; n=1; y_correct=1; assert(abs(Babylonian(a,n)-y_correct)<0.001);

i = 1 y = 1

2   Pass
a=10; n=1; y_correct=1; assert(abs(Babylonian(a,n)-y_correct)<0.001);

i = 1 y = 1

3   Pass
a=2; n=10; y_correct=1.4142; assert(abs(Babylonian(a,n)-y_correct)<0.001);

i = 1 y = 1 y = 1.5000 i = 2 y = 1.4167 i = 3 y = 1.4142 i = 4 y = 1.4142 i = 5 y = 1.4142 i = 6 y = 1.4142 i = 7 y = 1.4142 i = 8 y = 1.4142 i = 9 y = 1.4142 i = 10

4   Pass
a=4; n=10; y_correct=2; assert(abs(Babylonian(a,n)-y_correct)<0.001);

i = 1 y = 1 y = 2.5000 i = 2 y = 2.0500 i = 3 y = 2.0006 i = 4 y = 2.0000 i = 5 y = 2.0000 i = 6 y = 2 i = 7 y = 2 i = 8 y = 2 i = 9 y = 2 i = 10

5   Pass
a=0.25; n=10; y_correct=0.5; assert(abs(Babylonian(a,n)-y_correct)<0.001);

i = 1 y = 1 y = 0.6250 i = 2 y = 0.5125 i = 3 y = 0.5002 i = 4 y = 0.5000 i = 5 y = 0.5000 i = 6 y = 0.5000 i = 7 y = 0.5000 i = 8 y = 0.5000 i = 9 y = 0.5000 i = 10

6   Pass
a=30; n=4; y_correct=6.0795; assert(abs(Babylonian(a,n)-y_correct)<0.001);

i = 1 y = 1 y = 15.5000 i = 2 y = 8.7177 i = 3 y = 6.0795 i = 4