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

Solution 413353

Submitted on 4 Mar 2014 by Ehsan MahmoudzadehVazifeh

Correct

39Size
Leading solution size is 10.
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
 
%%
n = 1;
area_correct = 25;
tolerance = 1e-12;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
area =
    16
area =
    25
2
Pass
 
%%
n = 2;
area_correct = 41;
tolerance = 1e-12;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
area =
    16
area =
    25
area =
    41
3
Pass
 
%%
n = 3;
area_correct = 66;
tolerance = 1e-12;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
area =
    16
area =
    25
area =
    41
area =
    66
4
Pass
 
%%
n = 50;
area_correct = 439116598409;
tolerance = 1e-3;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
area =
    16
area =
    25
area =
    41
area =
    66
area =
   102
area =
   151
area =
   215
area =
   296
area =
   396
area =
   517
area =
   661
area =
   830
area =
        1026
area =
        1251
area =
        1507
area =
        1796
area =
        2120
area =
        2481
area =
        2881
area =
        3322
area =
        3806
area =
        4335
area =
        4911
area =
        5536
area =
        6212
area =
        6941
area =
        7725
area =
        8566
area =
        9466
area =
       10427
area =
       11451
area =
       12540
area =
       13696
area =
       14921
area =
       16217
area =
       17586
area =
       19030
area =
       20551
area =
       22151
area =
       23832
area =
       25596
area =
       27445
area =
       29381
area =
       31406
area =
       33522
area =
       35731
area =
       38035
area =
       40436
area =
       42936
area =
       45537
area =
       48241
area =
   4.3912e+11