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 227099

Submitted on 4 Apr 2013 by Tim

Correct

27Size
This is the leading solution.
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(within_circle(1),5))

	    	
2
Pass
 
%%
assert(isequal(within_circle(3),9))

	    	
3
Pass
 
%%
assert(isequal(within_circle(20),69))

	    	
4
Pass
 
%%
assert(isequal(within_circle(45),145))

	    	
5
Pass
 
%%
assert(isequal(within_circle(55),177))

	    	
6
Pass
 
%%
assert(isequal(within_circle(500),1581))

	    	
7
Pass
 
%%
assert(isequal(within_circle(10000),31417))

	    	
8
Pass
 
%%
assert(isequal(within_circle(50000),157093))

	    	
9
Pass
 
%%
assert(isequal(within_circle(999999),3141521))

	    	
10
Pass
 
%%
assert(isequal(within_circle(9999999),31415993))

	    	
11
Pass
 
%%
assert(isequal(within_circle(99999999),314159017)) % Approaching to Pi...

	    	
12
Pass
 
%%
filetext = fileread('within_circle.m');
assert(isempty(strfind(filetext, 'switch')))
assert(isempty(strfind(filetext, 'case')))
assert(isempty(strfind(filetext, 'if')))