Cody

# Problem 42405. Divisible by 3

Solution 3706793

Submitted on 18 Nov 2020
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
filetext = fileread('divisible_by_3.m'); assert(isempty(strfind(filetext, '*')),'* forbidden') assert(isempty(strfind(filetext, 'mtimes')),'mtimes() forbidden') assert(isempty(strfind(filetext, 'cross')),'cross() forbidden') assert(isempty(strfind(filetext, 'prod')),'prod() forbidden') assert(isempty(strfind(filetext, 'cumprod')),'cumprod() forbidden') assert(isempty(strfind(filetext, 'times')),'times() forbidden') assert(isempty(strfind(filetext, 'mldivide')),'mldivide() forbidden') assert(isempty(strfind(filetext, 'mrdivide')),'mrdivide() forbidden') assert(isempty(strfind(filetext, '/')),'/ forbidden') assert(isempty(strfind(filetext, '\')),'\ forbidden') assert(isempty(strfind(filetext, '^')),'^ forbidden') assert(isempty(strfind(filetext, 'dot')),'dot() forbidden') assert(isempty(strfind(filetext, 'rem')),'rem() forbidden') assert(isempty(strfind(filetext, 'mod')),'mod() forbidden') assert(isempty(strfind(filetext, 'round')),'round() forbidden') assert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden') assert(isempty(strfind(filetext, 'floor')),'floor() forbidden') assert(isempty(strfind(filetext, 'java')),'java forbidden')

2   Fail
n_str = '12'; assert(isequal(divisible_by_3(n_str),1))

z = 0 z = 1 z = 3 n_str = '3' tf = 0

Assertion failed.

3   Pass
n_str = '13'; assert(isequal(divisible_by_3(n_str),0))

z = 0 z = 1 z = 4 n_str = '4' tf = 0

4   Fail
n_str = '222'; assert(isequal(divisible_by_3(n_str),1))

z = 0 z = 2 z = 4 z = 6 n_str = '6' tf = 0

Assertion failed.

5   Pass
n_str = '232'; assert(isequal(divisible_by_3(n_str),0))

z = 0 z = 2 z = 5 z = 7 n_str = '7' tf = 0

6   Pass
n_str = '223'; assert(isequal(divisible_by_3(n_str),0))

z = 0 z = 2 z = 4 z = 7 n_str = '7' tf = 0

7   Pass
n_str = '1236127'; assert(isequal(divisible_by_3(n_str),0))

z = 0 z = 1 z = 3 z = 6 z = 12 z = 13 z = 15 z = 22 n_str = '22' z = 0 z = 2 z = 4 n_str = '4' tf = 0

8   Fail
n_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; assert(isequal(divisible_by_3(n_str),1))

z = 0 z = 1 z = 3 z = 6 z = 10 z = 15 z = 21 z = 28 z = 36 z = 45 z = 45 z = 46 z = 48 z = 51 z = 55 z = 60 z = 66 z = 73 z = 81 z = 90 z = 90 z = 91 z = 93 z = 96 z = 100 z = 105 z = 111 z = 118 z = 126 z = 135 z = 135 z = 136 z = 138 z = 141 z = 145 z = 150 z = 156 z = 163 z = 171 z = 180 z = 180 z = 181 z = 183 z = 186 z = 190 z = 195 z = 201 z = 208 z = 216 z = 225 z = 225 z = 226 z = 228 z = 231 z = 235 z = 240 z = 246 z = 253 z = 261 z = 270 z = 270 z = 271 z = 273 z = 276 z = 280 z = 285 z = 291 z = 298 z = 306 z = 315 z = 315 z = 316 z = 318 z = 321 z = 325 z = 330 z = 336 z = 343 z = 351 z = 360 z = 360 z = 361 z = 363 z = 366 z = 370 z = 375 z = 381 z = 388 z = 396 z = 405 z = 405 z = 406 z = 408 z = 411 z = 415 z = 420 z = 426 z = 433 z = 441 z = 450 z = 450 z = 451 z = 453 z = 456 z = 460 z = 465 z = 471 z = 478 z = 486 z = 495 z = 495 z = 496 z = 498 z = 501 z = 505 z = 510 z = 516 z = 523 z = 531 z = 540 z = 540 z = 541 z = 543 z = 546 z = 550 z = 555 z = 561 z = 568 z = 576 z = 585 z = 585 z = 586 z = 588 z = 591 z = 595 z = 600 z = 606 z = 613 z = 621 z = 630 z = 630 z = 631 z = 633 z = 636 z = 640 z = 645 z = 651 z = 658 z = 666 z = 675 z = 675 z = 676 z = 678 z = 681 z = 685 z = 690 z = 696 z = 703 z = 711 z = 720 z = 720 z = 721 z = 723 z = 726 z = 730 z = 735 z = 741 z = 748 z = 756 z = 765 z = 765 z = 766 z = 768 z = 771 z = 775 z = 780 z = 786 z = 793 z = 801 z = 810 z = 810 n_str = '810' z = 0 z = 8 z = 9 z = 9 n_str = '9' tf = 0

Assertion failed.

9   Pass
n_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901'; assert(isequal(divisible_by_3(n_str),0))

z = 0 z = 1 z = 3 z = 6 z = 10 z = 15 z = 21 z = 28 z = 36 z = 45 z = 45 z = 46 z = 48 z = 51 z = 55 z = 60 z = 66 z = 73 z = 81 z = 90 z = 90 z = 91 z = 93 z = 96 z = 100 z = 105 z = 111 z = 118 z = 126 z = 135 z = 135 z = 136 z = 138 z = 141 z = 145 z = 150 z = 156 z = 163 z = 171 z = 180 z = 180 z = 181 z = 183 z = 186 z = 190 z = 195 z = 201 z = 208 z = 216 z = 225 z = 225 z = 226 z = 228 z = 231 z = 235 z = 240 z = 246 z = 253 z = 261 z = 270 z = 270 z = 271 z = 273 z = 276 z = 280 z = 285 z = 291 z = 298 z = 306 z = 315 z = 315 z = 316 z = 318 z = 321 z = 325 z = 330 z = 336 z = 343 z = 351 z = 360 z = 360 z = 361 z = 363 z = 366 z = 370 z = 375 z = 381 z = 388 z = 396 z = 405 z = 405 z = 406 z = 408 z = 411 z = 415 z = 420 z = 426 z = 433 z = 441 z = 450 z = 450 z = 451 z = 453 z = 456 z = 460 z = 465 z = 471 z = 478 z = 486 z = 495 z = 495 z = 496 z = 498 z = 501 z = 505 z = 510 z = 516 z = 523 z = 531 z = 540 z = 540 z = 541 z = 543 z = 546 z = 550 z = 555 z = 561 z = 568 z = 576 z = 585 z = 585 z = 586 z = 588 z = 591 z = 595 z = 600 z = 606 z = 613 z = 621 z = 630 z = 630 z = 631 z = 633 z = 636 z = 640 z = 645 z = 651 z = 658 z = 666 z = 675 z = 675 z = 676 z = 678 z = 681 z = 685 z = 690 z = 696 z = 703 z = 711 z = 720 z = 720 z = 721 z = 723 z = 726 z = 730 z = 735 z = 741 z = 748 z = 756 z = 765 z = 765 z = 766 z = 768 z = 771 z = 775 z = 780 z = 786 z = 793 z = 801 z = 810 z = 810 z = 811 n_str = '811' z = 0 z = 8 z = 9 z = 10 n_str = '10' z = 0 z = 1 z = 1 n_str = '1' tf = 0

10   Fail
n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; assert(isequal(divisible_by_3(n_str),1))

z = 0 z = 1 z = 3 z = 6 z = 12 z = 19 z = 27 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 n_str = '36' z = 0 z = 3 z = 9 n_str = '9' tf = 0

Assertion failed.

11   Pass
n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'; assert(isequal(divisible_by_3(n_str),0))

z = 0 z = 1 z = 3 z = 6 z = 12 z = 19 z = 27 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 36 z = 37 n_str = '37' z = 0 z = 3 z = 10 n_str = '10' z = 0 z = 1 z = 1 n_str = '1' tf = 0

12   Fail
n_str = '3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198938095257201065485863278865936153381827968230301952035301852968995773622599413891249721775283479131515574857242454150695950829533116861727855889075098381754637464939319255060400927701671139009848824012858361603563707660104710181942955596198946767837449448255379774726847104047534646208046684259069491293313677028989152104752162056966024058038150193511253382430035587640247496473263914199272604269922796'; assert(isequal(divisible_by_3(n_str),1))

z = 0 z = 3 z = 4 z = 8 z = 9 z = 14 z = 23 z = 25 z = 31 z = 36 z = 39 z = 44 z = 52 z = 61 z = 68 z = 77 z = 80 z = 82 z = 85 z = 93 z = 97 z = 103 z = 105 z = 111 z = 115 z = 118 z = 121 z = 129 z = 132 z = 134 z = 141 z = 150 z = 155 z = 155 z = 157 z = 165 z = 173 z = 177 z = 178 z = 187 z = 194 z = 195 z = 201 z = 210 z = 213 z = 222 z = 231 z = 234 z = 241 z = 246 z = 247 z = 247 z = 252 z = 260 z = 262 z = 262 z = 271 z = 278 z = 282 z = 291 z = 295 z = 299 z = 304 z = 313 z = 315 z = 318 z = 318 z = 325 z = 333 z = 334 z = 340 z = 344 z = 344 z = 350 z = 352 z = 360 z = 366 z = 368 z = 368 z = 376 z = 385 z = 394 z = 402 z = 408 z = 410 z = 418 z = 418 z = 421 z = 425 z = 433 z = 435 z = 440 z = 443 z = 447 z = 449 z = 450 z = 451 z = 458 z = 458 z = 464 z = 471 z = 480 z = 488 z = 490 z = 491 z = 495 z = 503 z = 503 z = 511 z = 517 z = 522 z = 523 z = 526 z = 528 z = 536 z = 538 z = 541 z = 541 z = 547 z = 553 z = 557 z = 564 z = 564 z = 573 z = 576 z = 584 z = 588 z = 592 z = 598 z = 598 z = 607 z = 612 z = 617 z = 617 z = 622 z = 630 z = 632 z = 634 z = 637 z = 638 z = 645 z = 647 z = 652 z = 655 z = 660 z = 669 z = 673 z = 673 z = 681 z = 682 z = 684 z = 692 z = 696 z = 704 z = 705 z = 706 z = 707 z = 714 z = 718 z = 723 z = 723 z = 725 z = 733 z = 737 z = 738 z = 738 z = 740 z = 747 z = 747 z = 748 z = 757 z = 760 z = 768 z = 773 z = 775 z = 776 z = 777 z = 777 z = 782 z = 787 z = 792 z = 801 z = 807 z = 811 z = 815 z = 821 z = 823 z = 825 z = 834 z = 838 z = 846 z = 855 z = 860 z = 864 z = 873 z = 876 z = 876 z = 879 z = 887 z = 888 z = 897 z = 903 z = 907 z = 911 z = 913 z = 921 z = 929 z = 930 z = 930 z = 939 z = 946 z = 951 z = 957 z = 963 z = 968 z = 977 z = 980 z = 983 z = 987 z = 991 z = 997 z = 998 z = 1000 z = 1008 z = 1012 z = 1019 z = 1024 z = 1030 z = 1034 z = 1042 z = 1044 z = 1047 z = 1050 z = 1057 z = 1065 z = 1071 z = 1078 z = 1086 z = 1089 z = 1090 z = 1096 z = 1101 z = 1103 z = 1110 z = 1111 z = 1113 z = 1113 z = 1114 z = 1123 z = 1123 z = 1132 z = 1133 z = 1137 z = 1142 z = 1148 z = 1152 z = 1160 z = 1165 z = 1171 z = 1177 z = 1186 z = 1188 z = 1191 z = 1195 z = 1201 z = 1201 z = 1204 z = 1208 z = 1216 z = 1222 z = 1223 z = 1223 z = 1227 z = 1232 z = 1236 z = 1239 z = 1241 z = 1247 z = 1253 z = 1257 z = 1265 z = 1267 z = 1268 z = 1271 z = 1274 z = 1283 z = 1286 z = 1292 z = 1292 z = 1299 z = 1301 z = 1307 z = 1307 z = 1309 z = 1313 z = 1322 z = 1323 z = 1327 z = 1328 z = 1330 z = 1337 z = 1340 z = 1347 z = 1349 z = 1353 z = 1358 z = 1366 z = 1373 z = 1373 z = 1373 z = 1379 z = 1385 z = 1385 z = 1391 z = 1394 z = 1395 z = 1400 z = 1405 z = 1413 z = 1421 z = 1422 z = 1429 z = 1433 z = 1441 z = 1449 z = 1450 z = 1455 z = 1457 z = 1457 z = 1466 z = 1468 z = 1468 z = 1477 z = 1483 z = 1485 z = 1493 z = 1495 z = 1504 z = 1506 z = 1511 z = 1515 z = 1515 z = 1524 z = 1525 z = 1532 z = 1533 z = 1538 z = 1541 z = 1547 z = 1551 z = 1554 z = 1560 z = 1567 z = 1575 z = 1584 z = 1586 z = 1591 z = 1600 z = 1600 z = 1603 z = 1609 z = 1609 z = 1609 z = 1610 z = 1611 z = 1614 z = 1617 z = 1617 z = 1622 z = 1625 z = 1625 z = 1630 z = 1634 z = 1642 z = 1650 z = 1652 z = 1652 z = 1656 z = 1662 z = 1668 z = 1673 z = 1675 z = 1676 z = 1679 z = 1687 z = 1691 z = 1692 z = 1696 z = 1702 z = 1711 z = 1716 z = 1717 z = 1726 z = 1730 z = 1731 z = 1736 z = 1737 z = 1738 z = 1744 z = 1744 z = 1753 z = 1757 z = 1760 z = 1763 z = 1763 z = 1768 z = 1775 z = 1777 z = 1784 z = 1784 z = 1787 z = 1793 z = 1798 z = 1805 z = 1810 z = 1819 z = 1824 z = 1833 z = 1834 z = 1843 z = 1848 z = 1851 z = 1851 z = 1860 z = 1862 z = 1863 z = 1871 z = 1877 z = 1878 z = 1879 z = 1886 z = 1889 z = 1897 z = 1898 z = 1907 z = 1910 z = 1912 z = 1918 z = 1919 z = 1920 z = 1927 z = 1936 z = 1939 z = 1940 z = 1940 z = 1945 z = 1946 z = 1947 z = 1955 z = 1960 z = 1964 z = 1972 z = 1972 z = 1979 z = 1983 z = 1987 z = 1993 z = 1995 z = 1998 z = 2005 z = 2014 z = 2023 z = 2029 z = 2031 z = 2038 z = 2042 z = 2051 z = 2056 z = 2062 z = 2069 z = 2072 z = 2077 z = 2078 z = 2086 z = 2094 z = 2099 z = 2106 z = 2111 z = 2113 z = 2120 z = 2122 z = 2126 z = 2134 z = 2143 z = 2144 z = 2146 z = 2148 z = 2155 z = 2164 z = 2167 z = 2175 z = 2176 z = 2184 z = 2187 z = 2187 z = 2188 z = 2189 z = 2198 z = 2202 z = 2211 z = 2212 z = 2214 z = 2223 z = 2231 z = 2234 z = 2237 z = 2243 z = 2250 z = 2253 z = 2256 z = 2262 z = 2264 z = 2268 z = 2272 z = 2272 z = 2278 z = 2283 z = 2289 z = 2295 z = 2299 z = 2302 z = 2302 z = 2310 z = 2316 z = 2316 z = 2318 z = 2319 z = 2322 z = 2331 z = 2335 z = 2344 z = 2348 z = 2354 z = 2357 z = 2366 z = 2371 z = 2373 z = 2375 z = 2379 z = 2386 z = 2389 z = 2396 z = 2397 z = 2406 z = 2406 z = 2413 z = 2413 z = 2415 z = 2416 z = 2423 z = 2432 z = 2440 z = 2446 z = 2446 z = 2455 z = 2459 z = 2462 z = 2469 z = 2469 z = 2471 z = 2478 z = 2485 z = 2485 z = 2490 z = 2493 z = 2502 z = ...

Assertion failed.

13   Fail
n_str = '1010010101011010101001011010100101101010010100101101010011010100101'; assert(isequal(divisible_by_3(n_str),1))

z = 0 z = 1 z = 1 z = 2 z = 2 z = 2 z = 3 z = 3 z = 4 z = 4 z = 5 z = 5 z = 6 z = 7 z = 7 z = 8 z = 8 z = 9 z = 9 z = 10 z = 10 z = 10 z = 11 z = 11 z = 12 z = 13 z = 13 z = 14 z = 14 z = 15 z = 15 z = 15 z = 16 z = 16 z = 17 z = 18 z = 18 z = 19 z = 19 z = 20 z = 20 z = 20 z = 21 z = 21 z = 22 z = 22 z = 22 z = 23 z = 23 z = 24 z = 25 z = 25 z = 26 z = 26 z = 27 z = 27 z = 27 z = 28 z = 29 z = 29 z = 30 z = 30 z = 31 z = 31 z = 31 z = 32 z = 32 z = 33 n_str = '33' z = 0 z = 3 z = 6 n_str = '6' tf = 0

Assertion failed.

14   Fail
ind = randi(4); switch ind case 1 n_str = '12'; assert(isequal(divisible_by_3(n_str),1)) case 2 n_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901'; assert(isequal(divisible_by_3(n_str),0)) case 3 n_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; assert(isequal(divisible_by_3(n_str),1)) case 4 n_str = '1236127'; assert(isequal(divisible_by_3(n_str),0)) end

z = 0 z = 1 z = 3 z = 6 z = 10 z = 15 z = 21 z = 28 z = 36 z = 45 z = 45 z = 46 z = 48 z = 51 z = 55 z = 60 z = 66 z = 73 z = 81 z = 90 z = 90 z = 91 z = 93 z = 96 z = 100 z = 105 z = 111 z = 118 z = 126 z = 135 z = 135 z = 136 z = 138 z = 141 z = 145 z = 150 z = 156 z = 163 z = 171 z = 180 z = 180 z = 181 z = 183 z = 186 z = 190 z = 195 z = 201 z = 208 z = 216 z = 225 z = 225 z = 226 z = 228 z = 231 z = 235 z = 240 z = 246 z = 253 z = 261 z = 270 z = 270 z = 271 z = 273 z = 276 z = 280 z = 285 z = 291 z = 298 z = 306 z = 315 z = 315 z = 316 z = 318 z = 321 z = 325 z = 330 z = 336 z = 343 z = 351 z = 360 z = 360 z = 361 z = 363 z = 366 z = 370 z = 375 z = 381 z = 388 z = 396 z = 405 z = 405 z = 406 z = 408 z = 411 z = 415 z = 420 z = 426 z = 433 z = 441 z = 450 z = 450 z = 451 z = 453 z = 456 z = 460 z = 465 z = 471 z = 478 z = 486 z = 495 z = 495 z = 496 z = 498 z = 501 z = 505 z = 510 z = 516 z = 523 z = 531 z = 540 z = 540 z = 541 z = 543 z = 546 z = 550 z = 555 z = 561 z = 568 z = 576 z = 585 z = 585 z = 586 z = 588 z = 591 z = 595 z = 600 z = 606 z = 613 z = 621 z = 630 z = 630 z = 631 z = 633 z = 636 z = 640 z = 645 z = 651 z = 658 z = 666 z = 675 z = 675 z = 676 z = 678 z = 681 z = 685 z = 690 z = 696 z = 703 z = 711 z = 720 z = 720 z = 721 z = 723 z = 726 z = 730 z = 735 z = 741 z = 748 z = 756 z = 765 z = 765 z = 766 z = 768 z = 771 z = 775 z = 780 z = 786 z = 793 z = 801 z = 810 z = 810 n_str = '810' z = 0 z = 8 z = 9 z = 9 n_str = '9' tf = 0

Assertion failed.

15   Fail
ind = randi(4); switch ind case 1 n_str = '1010010101011010101001011010100101101010010100101101010011010100101'; assert(isequal(divisible_by_3(n_str),1)) case 2 n_str = '12'; assert(isequal(divisible_by_3(n_str),1)) case 3 n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'; assert(isequal(divisible_by_3(n_str),0)) case 4 n_str = '13'; assert(isequal(divisible_by_3(n_str),0)) end

z = 0 z = 1 z = 3 n_str = '3' tf = 0

Assertion failed.

16   Pass
ind = randi(4); switch ind case 1 n_str = '13'; assert(isequal(divisible_by_3(n_str),0)) case 2 n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; assert(isequal(divisible_by_3(n_str),1)) case 3 n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'; assert(isequal(divisible_by_3(n_str),0)) case 4 n_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; assert(isequal(divisible_by_3(n_str),1)) end

z = 0 z = 1 z = 4 n_str = '4' tf = 0

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!