function area = triangle_sequence(n)
y(1)=3;
y(2)=4;
for i=1:n
y(i+2)=sqrt(y(i)^2+y(i+1)^2)
end
area = y(n+2)^2;
end
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
n = 1;
area_correct = 25;
tolerance = 1e-12;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
y =
3 4 5
|
2 | Pass |
n = 2;
area_correct = 41;
tolerance = 1e-12;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
y =
3 4 5
y =
3.0000 4.0000 5.0000 6.4031
|
3 | Pass |
n = 3;
area_correct = 66;
tolerance = 1e-12;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
y =
3 4 5
y =
3.0000 4.0000 5.0000 6.4031
y =
3.0000 4.0000 5.0000 6.4031 8.1240
|
4 | Pass |
n = 50;
area_correct = 439116598409;
tolerance = 1e-3;
assert(abs(triangle_sequence(n)-area_correct)<tolerance)
y =
3 4 5
y =
3.0000 4.0000 5.0000 6.4031
y =
3.0000 4.0000 5.0000 6.4031 8.1240
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865
y =
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Column 18
185.5667
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Columns 18 through 19
185.5667 236.0445
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Columns 18 through 20
185.5667 236.0445 300.2532
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Columns 18 through 21
185.5667 236.0445 300.2532 381.9280
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Columns 18 through 22
185.5667 236.0445 300.2532 381.9280 485.8199
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Columns 18 through 23
185.5667 236.0445 300.2532 381.9280 485.8199 617.9725
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Columns 18 through 24
185.5667 236.0445 300.2532 381.9280 485.8199 617.9725 786.0732
y =
Columns 1 through 17
3.0000 4.0000 5.0000 6.4031 8.1240 10.3441 13.1529 16.7332 21.2838 27.0740 34.4384 43.8064 55.7225 70.8802 90.1610 114.6865 145.8835
Columns 18 through 25
185.5667 236.0445 300.2532 381.9280 485.8199 617.9725 786.0732 999.9005
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 26
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 27
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 28
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179 2.0580
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 29
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179 2.0580 2.6178
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 30
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179 2.0580 2.6178 3.3299
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 31
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179 2.0580 2.6178 3.3299 4.2356
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 32
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179 2.0580 2.6178 3.3299 4.2356 5.3878
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 33
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179 2.0580 2.6178 3.3299 4.2356 5.3878 6.8534
y =
1.0e+03 *
Columns 1 through 17
0.0030 0.0040 0.0050 0.0064 0.0081 0.0103 0.0132 0.0167 0.0213 0.0271 0.0344 0.0438 0.0557 0.0709 0.0902 0.1147 0.1459
Columns 18 through 34
0.1856 0.2360 0.3003 0.3819 0.4858 0.6180 0.7861 0.9999 1.2719 1.6179 2.0580 2.6178 3.3299 4.2356 5.3878 6.8534 8.7177
y =
1.0e+04 *
Columns 1 through 17
0.0003 0.0004 0.0005 0.0006 0.0008 0.0010 0.0013 0.0017 0.0021 0.0027 0.0034 0.0044 0.0056 0.0071 0.0090 0.0115 0.0146
Columns 18 through 34
0.0186 0.0236 0.0300 0.0382 0.0486 0.0618 0.0786 0.1000 0.1272 0.1618 0.2058 0.2618 0.3330 0.4236 0.5388 0.6853 0.8718
Column 35
1.1089
y =
1.0e+04 *
Columns 1 through 17
0.0003 0.0004 0.0005 0.0006 0.0008 0.0010 0.0013 0.0017 0.0021 0.0027 0.0034 0.0044 0.0056 0.0071 0.0090 0.0115 0.0146
Columns 18 through 34
0.0186 0.0236 0.0300 0.0382 0.0486 0.0618 0.0786 0.1000 0.1272 0.1618 0.2058 0.2618 0.3330 0.4236 0.5388 0.6853 0.8718
Columns 35 through 36
1.1089 1.4106
y =
1.0e+04 *
Columns 1 through 17
0.0003 0.0004 0.0005 0.0006 0.0008 0.0010 0.0013 0.0017 0.0021 0.0027 0.0034 0.0044 0.0056 0.0071 0.0090 0.0115 0.0146
Columns 18 through 34
0.0186 0.0236 0.0300 0.0382 0.0486 0.0618 0.0786 0.1000 0.1272 0.1618 0.2058 0.2618 0.3330 0.4236 0.5388 0.6853 0.8718
Columns 35 through 37
1.1089 1.4106 1.7942
y =
1.0e+04 *
Columns 1 through 17
0.0003 0.0004 0.0005 0.0006 0.0008 0.0010 0.0013 0.0017 0.0021 0.0027 0.0034 0.0044 0.0056 0.0071 0.0090 0.0115 0.0146
Columns 18 through 34
0.0186 0.0236 0.0300 0.0382 0.0486 0.0618 0.0786 0.1000 0.1272 0.1618 0.2058 0.2618 0.3330 0.4236 0.5388 0.6853 0.8718
Columns 35 through 38
1.1089 1.4106 1.7942 2.2823
y =
1.0e+04 *
Columns 1 through 17
0.0003 0.0004 0.0005 0.0006 0.0008 0.0010 0.0013 0.0017 0.0021 0.0027 0.0034 0.0044 0.0056 0.0071 0.0090 0.0115 0.0146
Columns 18 through 34
0.0186 0.0236 0.0300 0.0382 0.0486 0.0618 0.0786 0.1000 0.1272 0.1618 0.2058 0.2618 0.3330 0.4236 0.5388 0.6853 0.8718
Columns 35 through 39
1.1089 1.4106 1.7942 2.2823 2.9032
y =
1.0e+04 *
Columns 1 through 17
0.0003 0.0004 0.0005 0.0006 0.0008 0.0010 0.0013 0.0017 0.0021 0.0027 0.0034 0.0044 0.0056 0.0071 0.0090 0.0115 0.0146
Columns 18 through 34
0.0186 0.0236 0.0300 0.0382 0.0486 0.0618 0.0786 0.1000 0.1272 0.1618 0.2058 0.2618 0.3330 0.4236 0.5388 0.6853 0.8718
Columns 35 through 40
1.1089 1.4106 1.7942 2.2823 2.9032 3.6929
y =
1.0e+04 *...
|
2486 Solvers
Number of 1s in a binary string
2826 Solvers
412 Solvers
2338 Solvers
2636 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!