Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Solution 129992

Submitted on 22 Aug 2012 by Khaled Hamed

Correct

64Size
Leading solution size is 44.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
assert(isequal(repeatingdec(1),'0'))
ans =
1.00000000000000

	    	
2
Pass
 
%%
assert(isequal(repeatingdec(3/7),'428571'))
ans =
0.42857142857143

	    	
3
Pass
 
%%
assert(isequal(repeatingdec(.3456345612323),''))
ans =
0.34563456123230

	    	
4
Pass
 
%%
assert(isequal(repeatingdec(1/pi),''))
ans =
0.31830988618379

	    	
5
Pass
 
%%
assert(isequal(repeatingdec(1/13),'076923'))
ans =
0.07692307692308

	    	
6
Pass
 
%%
assert(isequal(repeatingdec(2/33),'06'))
ans =
0.06060606060606

	    	
7
Pass
 
%%
assert(isequal(repeatingdec(.789789789789789789),'789'))
ans =
0.78978978978979

	    	
8
Pass
 
%%
assert(isequal(repeatingdec(.78978978938383838),''))
ans =
0.78978978938384

	    	
9
Pass
 
%%
assert(isequal(repeatingdec(1/exp(1)),''))
ans =
0.36787944117144

	    	
10
Pass
 
%%
assert(isequal(repeatingdec(.78787878787833333),''))
ans =
0.78787878787833

	    	
11
Pass
 
%%
assert(isequal(repeatingdec(.123451234512345),'12345'))
ans =
0.12345123451235

	    	
12
Pass
 
%%
assert(isequal(repeatingdec(1/100),''))
ans =
0.01000000000000

	    	
13
Pass
 
%%
assert(isequal(repeatingdec(1/62),''))
ans =
0.01612903225806

	    	
14
Pass
 
%%
assert(isequal(repeatingdec(1/16),''))
ans =
0.06250000000000

	    	
15
Pass
 
%%
assert(isequal(repeatingdec(1/91),'010989'))
ans =
0.01098901098901

	    	
16
Pass
 
%%
assert(isequal(repeatingdec(0),'0'))
ans =
0.00000000000000