Cody

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

Solution 807951

Submitted on 16 Jan 2016 by Shishir Patel
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))

result = Columns 1 through 9 1.0000 1.5616 2.0000 2.3723 2.7016 3.0000 3.2749 3.5311 3.7720 Columns 10 through 18 4.0000 4.2170 4.4244 4.6235 4.8151 5.0000 5.1789 5.3523 5.5208 Columns 19 through 27 5.6847 5.8443 6.0000 6.1521 6.3007 6.4462 6.5887 6.7284 6.8655 Columns 28 through 36 7.0000 7.1322 7.2621 7.3899 7.5156 7.6394 7.7614 7.8815 8.0000 Columns 37 through 45 8.1168 8.2321 8.3459 8.4582 8.5692 8.6788 8.7871 8.8941 9.0000 Columns 46 through 54 9.1047 9.2082 9.3107 9.4121 9.5125 9.6119 9.7103 9.8078 9.9043 Columns 55 through 63 10.0000 10.0948 10.1888 10.2819 10.3743 10.4659 10.5567 10.6467 10.7361 Columns 64 through 72 10.8248 10.9127 11.0000 11.0866 11.1726 11.2580 11.3427 11.4269 11.5104 Columns 73 through 81 11.5934 11.6758 11.7577 11.8390 11.9197 12.0000 12.0797 12.1590 12.2377 Columns 82 through 90 12.3160 12.3938 12.4711 12.5480 12.6244 12.7004 12.7759 12.8510 12.9257 Columns 91 through 99 13.0000 13.0739 13.1473 13.2204 13.2931 13.3654 13.4374 13.5089 13.5801 Column 100 13.6510 y = Columns 1 through 16 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 Columns 17 through 32 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 Columns 33 through 48 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 Columns 49 through 64 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Columns 65 through 80 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 Columns 81 through 96 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 Columns 97 through 100 0 0 0 0

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

result = 1 y = 1

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

result = 1.0e+04 * 9.9123 9.9123 y = 0 1