Cody

Problem 918. Find the repeating decimal pattern!

Solution 849374

Submitted on 11 Mar 2016
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   Fail
assert(isequal(repeatingdec(1),'0'))

y = 1 out = 0

Error using repeatingdec (line 10) Index exceeds matrix dimensions.

2   Fail
assert(isequal(repeatingdec(3/7),'428571'))

y = 0.4285714285714285 str = 4285 str = 4285714285

Assertion failed.

3   Pass
assert(isequal(repeatingdec(.3456345612323),''))

y = 0.3456345612323 str = 34 str = 34563456 str = 3456345612

4   Pass
assert(isequal(repeatingdec(1/pi),''))

y = 0.3183098861837907 str = 3 str = 318309886

5   Pass
assert(isequal(repeatingdec(1/13),'076923'))

y = 0.07692307692307693 str = Empty matrix: 1-by-0 str = 076923

6   Pass
assert(isequal(repeatingdec(2/33),'06'))

y = 0.06060606060606061 str = Empty matrix: 1-by-0 str = 06

7   Fail
assert(isequal(repeatingdec(.789789789789789789),'789'))

y = 0.7897897897897898 str = 7 str = 7897 str = 7897897 str = 7897897897

Assertion failed.

8   Pass
assert(isequal(repeatingdec(.78978978938383838),''))

y = 0.7897897893838384 str = 7 str = 7897

9   Pass
assert(isequal(repeatingdec(1/exp(1)),''))

y = 0.3678794411714423 str = 3678794411714

10   Pass
assert(isequal(repeatingdec(.78787878787833333),''))

y = 0.7878787878783333 str = Empty matrix: 1-by-0 str = 78 str = 7878 str = 787878 str = 78787878

11   Fail
assert(isequal(repeatingdec(.123451234512345),'12345'))

y = 0.123451234512345 str = 123 str = 12345123

Assertion failed.

12   Pass
assert(isequal(repeatingdec(1/100),''))

y = 0.01 str = Empty matrix: 1-by-0

13   Pass
assert(isequal(repeatingdec(1/62),''))

y = 0.01612903225806452 str = Empty matrix: 1-by-0 str = 016129 str = 016129032258

14   Pass
assert(isequal(repeatingdec(1/16),''))

y = 0.0625 str = Empty matrix: 1-by-0

15   Pass
assert(isequal(repeatingdec(1/91),'010989'))

y = 0.01098901098901099 str = Empty matrix: 1-by-0 str = 01 str = 010989

16   Fail
assert(isequal(repeatingdec(0),'0'))

y = 0 out = 0

Error using repeatingdec (line 10) Index exceeds matrix dimensions.