Cody

# Problem 2024. Triangle sequence

Solution 1002435

Submitted on 8 Oct 2016 by Matteo Malacarne
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)

s = 3 4 5 area = 25

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

s = 3 4 5 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 area = 41

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

s = 3 4 5 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 area = 66.0000

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

s = 3 4 5 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 145.8835 185.5667 236.0445 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 145.8835 185.5667 236.0445 185.5667 236.0445 300.2532 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 145.8835 185.5667 236.0445 185.5667 236.0445 300.2532 236.0445 300.2532 381.9280 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 145.8835 185.5667 236.0445 185.5667 236.0445 300.2532 236.0445 300.2532 381.9280 300.2532 381.9280 485.8199 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 145.8835 185.5667 236.0445 185.5667 236.0445 300.2532 236.0445 300.2532 381.9280 300.2532 381.9280 485.8199 381.9280 485.8199 617.9725 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 145.8835 185.5667 236.0445 185.5667 236.0445 300.2532 236.0445 300.2532 381.9280 300.2532 381.9280 485.8199 381.9280 485.8199 617.9725 485.8199 617.9725 786.0732 s = 3.0000 4.0000 5.0000 4.0000 5.0000 6.4031 5.0000 6.4031 8.1240 6.4031 8.1240 10.3441 8.1240 10.3441 13.1529 10.3441 13.1529 16.7332 13.1529 16.7332 21.2838 16.7332 21.2838 27.0740 21.2838 27.0740 34.4384 27.0740 34.4384 43.8064 34.4384 43.8064 55.7225 43.8064 55.7225 70.8802 55.7225 70.8802 90.1610 70.8802 90.1610 114.6865 90.1610 114.6865 145.8835 114.6865 145.8835 185.5667 145.8835 185.5667 236.0445 185.5667 236.0445 300.2532 236.0445 300.2532 381.9280 300.2532 381.9280 485.8199 381.9280 485.8199 617.9725 485.8199 617.9725 786.0732 617.9725 786.0732 999.9005 s = 1.0e+03 * 0.0030 0.0040 0.0050 0.0040 0.0050 0.0064 0.0050 0.0064 0.0081 0.0064 0.0081 0.0103 0.0081 0.0103 0.0132 0.0103 0.0132 0.0167 0.0132 0.0167 0.0213 0.0167 0.0213 0.0271 0.0213 0.0271 0.0344 0.0271 0.0344 0.0438 0.0344 0.0438 0.0557 0.0438 0.0557 0.0709 0.0557 0.0709 0.0902 0.0709 0.0902 0.1147 0.0902 0.1147 0.1459 0.1147 0.1459 0.1856 0.1459 0.1856 0.2360 0.1856 0.2360 0.3003 0.2360 0.3003 0.3819 0.3003 0.3819 0.4858 0.3819 0.4858 0.6180 0.4858 0.6180 0.7861 0.6180 0.7861 0.9999 0.7861 0.9999 1.2719 s = 1.0e+03 * 0.0030 0.0040 0.0050 0.0040 0.0050 0.0064 0.0050 0.0064 0.0081 0.0064 0.0081 0.0103 0.0081 0.0103 0.0132 0.0103 0.0132 0.0167 0.0132 0.0167 0.0213 0.0167 0.0213 0.0271 0.0213 0.0271 0.0344 0.0271 0.0344 0.0438 0.0344 0.0438 0.0557 0.0438 0.0557 0.0709 0.0557 0.0709 0.0902 0.0709 0.0902 0.1147 0.0902 0.1147 0.1459 0.1147 0.1459 0.1856 0.1459 0...