Cody

Problem 2024. Triangle sequence

Solution 433093

Submitted on 17 Apr 2014 by Joel
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   Pass
%% n = 1; area_correct = 25; tolerance = 1e-12; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

shortest = 3 middle = 4 longestside = 5 ii = 1 area = 25

2   Pass
%% n = 2; area_correct = 41; tolerance = 1e-12; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

shortest = 3 middle = 4 longestside = 5 ii = 1 shortest = 4 middle = 5 longestside = 6.4031 ii = 2 area = 41

3   Pass
%% n = 3; area_correct = 66; tolerance = 1e-12; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

shortest = 3 middle = 4 longestside = 5 ii = 1 shortest = 4 middle = 5 longestside = 6.4031 ii = 2 shortest = 5 middle = 6.4031 longestside = 8.1240 ii = 3 area = 66.0000

4   Pass
%% n = 50; area_correct = 439116598409; tolerance = 1e-3; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

shortest = 3 middle = 4 longestside = 5 ii = 1 shortest = 4 middle = 5 longestside = 6.4031 ii = 2 shortest = 5 middle = 6.4031 longestside = 8.1240 ii = 3 shortest = 6.4031 middle = 8.1240 longestside = 10.3441 ii = 4 shortest = 8.1240 middle = 10.3441 longestside = 13.1529 ii = 5 shortest = 10.3441 middle = 13.1529 longestside = 16.7332 ii = 6 shortest = 13.1529 middle = 16.7332 longestside = 21.2838 ii = 7 shortest = 16.7332 middle = 21.2838 longestside = 27.0740 ii = 8 shortest = 21.2838 middle = 27.0740 longestside = 34.4384 ii = 9 shortest = 27.0740 middle = 34.4384 longestside = 43.8064 ii = 10 shortest = 34.4384 middle = 43.8064 longestside = 55.7225 ii = 11 shortest = 43.8064 middle = 55.7225 longestside = 70.8802 ii = 12 shortest = 55.7225 middle = 70.8802 longestside = 90.1610 ii = 13 shortest = 70.8802 middle = 90.1610 longestside = 114.6865 ii = 14 shortest = 90.1610 middle = 114.6865 longestside = 145.8835 ii = 15 shortest = 114.6865 middle = 145.8835 longestside = 185.5667 ii = 16 shortest = 145.8835 middle = 185.5667 longestside = 236.0445 ii = 17 shortest = 185.5667 middle = 236.0445 longestside = 300.2532 ii = 18 shortest = 236.0445 middle = 300.2532 longestside = 381.9280 ii = 19 shortest = 300.2532 middle = 381.9280 longestside = 485.8199 ii = 20 shortest = 381.9280 middle = 485.8199 longestside = 617.9725 ii = 21 shortest = 485.8199 middle = 617.9725 longestside = 786.0732 ii = 22 shortest = 617.9725 middle = 786.0732 longestside = 999.9005 ii = 23 shortest = 786.0732 middle = 999.9005 longestside = 1.2719e+03 ii = 24 shortest = 999.9005 middle = 1.2719e+03 longestside = 1.6179e+03 ii = 25 shortest = 1.2719e+03 middle = 1.6179e+03 longestside = 2.0580e+03 ii = 26 shortest = 1.6179e+03 middle = 2.0580e+03 longestside = 2.6178e+03 ii = 27 shortest = 2.0580e+03 middle = 2.6178e+03 longestside = 3.3299e+03 ii = 28 shortest = 2.6178e+03 middle = 3.3299e+03 longestside = 4.2356e+03 ii = 29 shortest = 3.3299e+03 middle = 4.2356e+03 longestside = 5.3878e+03 ii = 30 shortest = 4.2356e+03 middle = 5.3878e+03 longestside = 6.8534e+03 ii = 31 shortest = 5.3878e+03 middle = 6.8534e+03 longestside = 8.7177e+03 ii = 32 shortest = 6.8534e+03 middle = 8.7177e+03 longestside = 1.1089e+04 ii = 33 shortest = 8.7177e+03 middle = 1.1089e+04 longestside = 1.4106e+04 ii = 34 shortest = 1.1089e+04 middle = 1.4106e+04 longestside = 1.7942e+04 ii = 35 shortest = 1.4106e+04 middle = 1.7942e+04 longestside = 2.2823e+04 ii = 36 shortest = 1.7942e+04 middle = 2.2823e+04 longestside = 2.9032e+04 ii = 37 shortest = 2.2823e+04 middle = 2.9032e+04 longestside = 3.6929e+04 ii = 38 shortest = 2.9032e+04 middle = 3.6929e+04 longestside = 4.6974e+04 ii = 39 shortest = 3.6929e+04 middle = 4.6974e+04 longestside = 5.9752e+04 ii = 40 shortest = 4.6974e+04 middle = 5.9752e+04 longestside = 7.6006e+04 ii = 41 shortest = 5.9752e+04 middle = 7.6006e+04 longestside = 9.6681e+04 ii = 42 shortest = 7.6006e+04 middle = 9.6681e+04 longestside = 1.2298e+05 ii = 43 shortest = 9.6681e+04 middle = 1.2298e+05 longestside = 1.5643e+05 ii = 44 shortest = 1.2298e+05 middle = 1.5643e+05 longestside = 1.9899e+05 ii = 45 shortest = 1.5643e+05 middle = 1.9899e+05 longestside = 2.5311e+05 ii = 46 shortest = 1.9899e+05 middle = 2.5311e+05 longestside = 3.2196e+05 ii = 47 shortest = 2.5311e+05 middle = 3.2196e+05 longestside = 4.0955e+05 ii = 48 shortest = 3.2196e+05 middle = 4.0955e+05 longestside = 5.2095e+05 ii = 49 shortest = 4.0955e+05 middle = 5.2095e+05 longestside = 6.6266e+05 ii = 50 area = 4.3912e+11