Cody

# Problem 139. Determine if a Given Number is a Triangle Number

Solution 1996706

Submitted on 30 Oct 2019 by Asif Newaz
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
x = 1:100; y_correct = false(1,100); y_correct([1 3 6 10 15 21 28 36 45 55 66 78 91]) = true; assert(isequal(isTriangleNumber(x),y_correct))

b = -2 1 b = -2.5616 1.5616 b = -3 2 b = -3.3723 2.3723 b = -3.7016 2.7016 b = -4 3 b = -4.2749 3.2749 b = -4.5311 3.5311 b = -4.7720 3.7720 b = -5 4 b = -5.2170 4.2170 b = -5.4244 4.4244 b = -5.6235 4.6235 b = -5.8151 4.8151 b = -6 5 b = -6.1789 5.1789 b = -6.3523 5.3523 b = -6.5208 5.5208 b = -6.6847 5.6847 b = -6.8443 5.8443 b = -7 6 b = -7.1521 6.1521 b = -7.3007 6.3007 b = -7.4462 6.4462 b = -7.5887 6.5887 b = -7.7284 6.7284 b = -7.8655 6.8655 b = -8 7 b = -8.1322 7.1322 b = -8.2621 7.2621 b = -8.3899 7.3899 b = -8.5156 7.5156 b = -8.6394 7.6394 b = -8.7614 7.7614 b = -8.8815 7.8815 b = -9 8 b = -9.1168 8.1168 b = -9.2321 8.2321 b = -9.3459 8.3459 b = -9.4582 8.4582 b = -9.5692 8.5692 b = -9.6788 8.6788 b = -9.7871 8.7871 b = -9.8941 8.8941 b = -10 9 b = -10.1047 9.1047 b = -10.2082 9.2082 b = -10.3107 9.3107 b = -10.4121 9.4121 b = -10.5125 9.5125 b = -10.6119 9.6119 b = -10.7103 9.7103 b = -10.8078 9.8078 b = -10.9043 9.9043 b = -11 10 b = -11.0948 10.0948 b = -11.1888 10.1888 b = -11.2819 10.2819 b = -11.3743 10.3743 b = -11.4659 10.4659 b = -11.5567 10.5567 b = -11.6467 10.6467 b = -11.7361 10.7361 b = -11.8248 10.8248 b = -11.9127 10.9127 b = -12 11 b = -12.0866 11.0866 b = -12.1726 11.1726 b = -12.2580 11.2580 b = -12.3427 11.3427 b = -12.4269 11.4269 b = -12.5104 11.5104 b = -12.5934 11.5934 b = -12.6758 11.6758 b = -12.7577 11.7577 b = -12.8390 11.8390 b = -12.9197 11.9197 b = -13 12 b = -13.0797 12.0797 b = -13.1590 12.1590 b = -13.2377 12.2377 b = -13.3160 12.3160 b = -13.3938 12.3938 b = -13.4711 12.4711 b = -13.5480 12.5480 b = -13.6244 12.6244 b = -13.7004 12.7004 b = -13.7759 12.7759 b = -13.8510 12.8510 b = -13.9257 12.9257 b = -14 13 b = -14.0739 13.0739 b = -14.1473 13.1473 b = -14.2204 13.2204 b = -14.2931 13.2931 b = -14.3654 13.3654 b = -14.4374 13.4374 b = -14.5089 13.5089 b = -14.5801 13.5801 b = -14.6510 13.6510

2   Pass
x = 1; y_correct = true; assert(isequal(isTriangleNumber(x),y_correct))

b = -2 1

3   Pass
x = [4912734125;4912734126]; y_correct = [false;true]; assert(isequal(isTriangleNumber(x),y_correct))

b = 1.0e+04 * -9.9124 9.9123 b = -99124 99123