If the number is a true repeater, then multiplying it by 999... for some number of 9's will result in an integer. The difficulty lies in the rounding. I had to tune the tolerance to deal with cases like .123451234512345, which aren't truly repeating.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
assert(isequal(repeatingdec(1),'0'))
|
2 | Pass |
%%
assert(isequal(repeatingdec(3/7),'428571'))
|
3 | Pass |
%%
assert(isequal(repeatingdec(.3456345612323),''))
|
4 | Pass |
%%
assert(isequal(repeatingdec(1/pi),''))
|
5 | Pass |
%%
assert(isequal(repeatingdec(1/13),'076923'))
|
6 | Pass |
%%
assert(isequal(repeatingdec(2/33),'06'))
|
7 | Pass |
%%
assert(isequal(repeatingdec(.789789789789789789),'789'))
|
8 | Pass |
%%
assert(isequal(repeatingdec(.78978978938383838),''))
|
9 | Pass |
%%
assert(isequal(repeatingdec(1/exp(1)),''))
|
10 | Pass |
%%
assert(isequal(repeatingdec(.78787878787833333),''))
|
11 | Pass |
%%
assert(isequal(repeatingdec(.123451234512345),'12345'))
|
12 | Pass |
%%
assert(isequal(repeatingdec(1/100),''))
|
13 | Pass |
%%
assert(isequal(repeatingdec(1/62),''))
|
14 | Pass |
%%
assert(isequal(repeatingdec(1/16),''))
|
15 | Pass |
%%
assert(isequal(repeatingdec(1/91),'010989'))
|
16 | Pass |
%%
assert(isequal(repeatingdec(0),'0'))
|
Sort a list of complex numbers based on far they are from the origin.
3794 Solvers
Back to basics 24 - Symbolic variables
115 Solvers
230 Solvers
Make a logical diamond using GALLERY function
48 Solvers
The sum of the numbers in the vector
342 Solvers