Cody

# Problem 813. Multiply 2 numbers

Solution 184976

Submitted on 3 Jan 2013
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; y =2; y_correct = 2; assert(isequal(round(your_fcn_name(x,y)),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, '*')),'sign * 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'))) assert(isempty(strfind(filetext, 'times'))) assert(isempty(strfind(filetext, 'mldivide'))) assert(isempty(strfind(filetext, 'mrdivide'))) assert(isempty(strfind(filetext, '/')),'/ forbidden') assert(isempty(strfind(filetext, '\'))) assert(isempty(strfind(filetext, '-'))) assert(isempty(strfind(filetext, '^')),'^ forbidden') assert(isempty(strfind(filetext, 'dot'))) assert(isempty(strfind(filetext, '''')),'string forbidden')

``` output = 1 output = 2 ```

2   Pass
%% x = 8; y =25; y_correct = 200; assert(isequal(round(your_fcn_name(x,y)),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, '*'))) assert(isempty(strfind(filetext, 'mtimes'))) assert(isempty(strfind(filetext, 'cross'))) assert(isempty(strfind(filetext, 'prod'))) assert(isempty(strfind(filetext, 'cumprod'))) assert(isempty(strfind(filetext, 'times'))) assert(isempty(strfind(filetext, 'dot')))

``` output = 8 output = 16 output = 24 output = 32 output = 40 output = 48 output = 56 output = 64 output = 72 output = 80 output = 88 output = 96 output = 104 output = 112 output = 120 output = 128 output = 136 output = 144 output = 152 output = 160 output = 168 output = 176 output = 184 output = 192 output = 200 ```

3   Pass
%% x = 8; y =0; y_correct = 0; assert(isequal(round(your_fcn_name(x,y)),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, '*'))) assert(isempty(strfind(filetext, 'mtimes'))) assert(isempty(strfind(filetext, 'cross'))) assert(isempty(strfind(filetext, 'prod'))) assert(isempty(strfind(filetext, 'cumprod'))) assert(isempty(strfind(filetext, 'times'))) assert(isempty(strfind(filetext, 'dot')))

``` ```

4   Pass
%% x = -148; y =2865; y_correct = -424020; assert(isequal(round(your_fcn_name(x,y)),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, '*'))) assert(isempty(strfind(filetext, 'mtimes'))) assert(isempty(strfind(filetext, 'cross'))) assert(isempty(strfind(filetext, 'prod'))) assert(isempty(strfind(filetext, 'cumprod'))) assert(isempty(strfind(filetext, 'times'))) assert(isempty(strfind(filetext, 'dot')))

``` output = -148 output = -296 output = -444 output = -592 output = -740 output = -888 output = -1036 output = -1184 output = -1332 output = -1480 output = -1628 output = -1776 output = -1924 output = -2072 output = -2220 output = -2368 output = -2516 output = -2664 output = -2812 output = -2960 output = -3108 output = -3256 output = -3404 output = -3552 output = -3700 output = -3848 output = -3996 output = -4144 output = -4292 output = -4440 output = -4588 output = -4736 output = -4884 output = -5032 output = -5180 output = -5328 output = -5476 output = -5624 output = -5772 output = -5920 output = -6068 output = -6216 output = -6364 output = -6512 output = -6660 output = -6808 output = -6956 output = -7104 output = -7252 output = -7400 output = -7548 output = -7696 output = -7844 output = -7992 output = -8140 output = -8288 output = -8436 output = -8584 output = -8732 output = -8880 output = -9028 output = -9176 output = -9324 output = -9472 output = -9620 output = -9768 output = -9916 output = -10064 output = -10212 output = -10360 output = -10508 output = -10656 output = -10804 output = -10952 output = -11100 output = -11248 output = -11396 output = -11544 output = -11692 output = -11840 output = -11988 output = -12136 output = -12284 output = -12432 output = -12580 output = -12728 output = -12876 output = -13024 output = -13172 output = -13320 output = -13468 output = -13616 output = -13764 output = -13912 output = -14060 output = -14208 output = -14356 output = -14504 output = -14652 output = -14800 output = -14948 output = -15096 output = -15244 output = -15392 output = -15540 output = -15688 output = -15836 output = -15984 output = -16132 output = -16280 output = -16428 output = -16576 output = -16724 output = -16872 output = -17020 output = -17168 output = -17316 output = -17464 output = -17612 output = -17760 output = -17908 output = -18056 output = -18204 output = -18352 output = -18500 output = -18648 output = -18796 output = -18944 output = -19092 output = -19240 output = -19388 output = -19536 output = -19684 output = -19832 output = -19980 output = -20128 output = -20276 output = -20424 output = -20572 output = -20720 output = -20868 output = -21016 output = -21164 output = -21312 output = -21460 output = -21608 output = -21756 output = -21904 output = -22052 output = -22200 output = -22348 output = -22496 output = -22644 output = -22792 output = -22940 output = -23088 output = -23236 output = -23384 output = -23532 output = -23680 output = -23828 output = -23976 output = -24124 output = -24272 output = -24420 output = -24568 output = -24716 output = -24864 output = -25012 output = -25160 output = -25308 output = -25456 output = -25604 output = -25752 output = -25900 output = -26048 output = -26196 output = -26344 output = -26492 output = -26640 output = -26788 output = -26936 output = -27084 output = -27232 output = -27380 output = -27528 output = -27676 output = -27824 output = -27972 output = -28120 output = -28268 output = -28416 output = -28564 output = -28712 output = -28860 output = -29008 output = -29156 output = -29304 output = -29452 output = -29600 output = -29748 output = -29896 output = -30044 output = -30192 output = -30340 output = -30488 output = -30636 output = -30784 output = -30932 output = -31080 output = -31228 output = -31376 output = -31524 output = -31672 output = -31820 output = -31968 output = -32116 output = -32264 output = -32412 output = -32560 output = -32708 output = -32856 output = -33004 output = -33152 output = -33300 output = -33448 output = -33596 output = -33744 output = -33892 output = -34040 output = -34188 output = -34336 output = -34484 output = -34632 output = -34780 output = -34928 output = -35076 output = -35224 output = -35372 output = -35520 output = -35668 output = -35816 output = -35964 output = -36112 output = -36260 output = -36408 output = -36556 output = -36704 output = -36852 output = -37000 output = -37148 output = -37296 output = -37444 output = -37592 output = -37740 output = -37888 output = -38036 output = -38184 output = -38332 output = -38480 output = -38628 output = -38776 output = -38924 output = -39072 output = -39220 output = -39368 output = -39516 output = -39664 output = -39812 output = -39960 output = -40108 output = -40256 output = -40404 output = -40552 output = -40700 output = -40848 output = -40996 output = -41144 output = -41292 output = -41440 output = -41588 output = -41736 output = -41884 output = -42032 output = -42180 output = -42328 output = -42476 output = -42624 output = -42772 output = -42920 output = -43068 output = -43216 output = -43364 output = -43512 output = -43660 output = -43808 output = -43956 output = -44104 output = -44252 output = -44400 output = -44548 output = -44696 output = -44844 output = -44992 output = -45140 output = -45288 output = -45436 output = -45584 output = -45732 output = -45880 output = -46028 output = -46176 output = -46324 output = -46472 output = -46620 output = -46768 output = -46916 output = -47064 output = -47212 output = -47360 output = -47508 output = -47656 output = -47804 output = -47952 output = -48100 output = -48248 output = -48396 output = -48544 output = -48692 output = -48840 output = -48988 output = -49136 output = -49284 output = -49432 output = -49580 output = -49728 output = -49876 output = -50024 output = -50172 output = -50320 output = -50468 output = -50616 output = -50764 output = -50912 output = -51060 output = -51208 output = -51356 output = -51504 output = -51652 output = -51800 output = -51948 output = -52096 output = -52244 output = -52392 output = -52540 output = -52688 output = -52836 output = -52984 output = -53132 output = -53280 output = -53428 output = -53576 output = -53724 output = -53872 output = -54020 output = -54168 output = -54316 output = -54464 output = -54612 output = -54760 output = -54908 output = -55056 output = -55204 output = -55352 output = -55500 output = -55648 output = -55796 output = -55944 output = -56092 output = -56240 output = -56388 output = -56536 output = -56684 output = -56832 output = -56980 output = -57128 output = -57276 output = -57424 output = -57572 output = -57720 output = -57868 output = -58016 output = -58164 output = -58312 output = -58460 output = -58608 output = -58756 output = -58904 output = -59052 output = -59200 output = -59348 output = -59496 output = -59644 output = -59792 output = -59940 output = -60088 output = -60236 output = -60384 output = -60532 output = -60680 output = -60828 output = -60976 output = -61124 output = -61272 output = -61420 output = -61568 output = -61716 output = -61864 output = -62012 output = -62160 output = -62308 output = -62456 output = -62604 output = -62752 output = -62900 output = -63048 output = -63196 output = -63344 output = -63492 output = -63640 output = -63788 output = -63936 output = -64084 output = -64232 output = -64380 output = -64528 output = -64676 output = -64824 output = -64972 output = -65120 output = -65268 output = -65416 output = -65564 output = -65712 output = -65860 output = -66008 output = -66156 output = -66304 output = -66452 output = -66600 output = -66748 output = -66896 output = -67044 output = -67192 output = -67340 output = -67488 out...```

5   Fail
%% Test 5 : randi!! x = randi([1 58]); y =286.5; y_correct = x*y; assert(abs( your_fcn_name(x,y)-y_correct)<1e-9) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, '*'))) assert(isempty(strfind(filetext, 'mtimes'))) assert(isempty(strfind(filetext, 'cross'))) assert(isempty(strfind(filetext, 'prod'))) assert(isempty(strfind(filetext, 'cumprod'))) assert(isempty(strfind(filetext, 'times'))) assert(isempty(strfind(filetext, 'dot')))

```Error: Assertion failed. ```

6   Fail
%% Test 6 : randi and pi !! x = randi([14 580]); y = -pi; y_correct = x*y; assert(abs( your_fcn_name(x,y)-y_correct)<1e-9) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, '*'))) assert(isempty(strfind(filetext, 'mtimes'))) assert(isempty(strfind(filetext, 'cross'))) assert(isempty(strfind(filetext, 'prod'))) assert(isempty(strfind(filetext, 'cumprod'))) assert(isempty(strfind(filetext, 'times'))) assert(isempty(strfind(filetext, 'dot'))) assert(isempty(strfind(filetext, 'num2str'))) assert(isempty(strfind(filetext, 'int2str'))) assert(isempty(strfind(filetext, 'dec2bin')))

```Error: Assertion failed. ```