Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

23Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%% Test the example
A = 1;
iterations = 4;
y_correct8 = [1     3     7    15    31];
assert(isequal(your_fcn_name(A,iterations),y_correct8))
ans =
  Columns 1 through 4
          1.00          3.00          7.00         15.00
  Column 5
         31.00
2
Pass
 
%% More ietrations
A = 1;
iterations = 1000;
C= A
for i = 1:iterations
  C(i+1) = 2*C(i)+1;
end
assert(isequal(your_fcn_name(A,iterations),C))
C =
          1.00
ans =
  Columns 1 through 4
          1.00          3.00          7.00         15.00
  Columns 5 through 8
         31.00         63.00        127.00        255.00
  Columns 9 through 12
        511.00       1023.00       2047.00       4095.00
  Columns 13 through 16
       8191.00      16383.00      32767.00      65535.00
  Columns 17 through 20
     131071.00     262143.00     524287.00    1048575.00
  Columns 21 through 24
    2097151.00    4194303.00    8388607.00   16777215.00
  Columns 25 through 28
   33554431.00   67108863.00  134217727.00  268435455.00
  Columns 29 through 32
  536870911.00 1073741823.00 2147483647.00 4294967295.00
  Columns 33 through 36
 8589934591.00 17179869183.00 34359738367.00 68719476735.00
  Columns 37 through 40
 137438953471.00 274877906943.00 549755813887.00 1099511627775.00
  Columns 41 through 44
 2199023255551.00 4398046511103.00 8796093022207.00 17592186044415.00
  Columns 45 through 48
 35184372088831.00 70368744177663.00 140737488355327.00 281474976710655.00
  Columns 49 through 52
 562949953421311.00 1125899906842623.00 2251799813685247.00 4503599627370495.00
  Columns 53 through 56
 9007199254740991.00 18014398509481984.00 36028797018963968.00 72057594037927936.00
  Columns 57 through 60
 144115188075855872.00 288230376151711744.00 576460752303423488.00 1152921504606846976.00
  Columns 61 through 64
 2305843009213693952.00 4611686018427387904.00 9223372036854775808.00 18446744073709551616.00
  Columns 65 through 68
 36893488147419103232.00 73786976294838206464.00 147573952589676412928.00 295147905179352825856.00
  Columns 69 through 72
 590295810358705651712.00 1180591620717411303424.00 2361183241434822606848.00 4722366482869645213696.00
  Columns 73 through 76
 9444732965739290427392.00 18889465931478580854784.00 37778931862957161709568.00 75557863725914323419136.00
  Columns 77 through 80
 151115727451828646838272.00 302231454903657293676544.00 604462909807314587353088.00 1208925819614629174706176.00
  Columns 81 through 84
 2417851639229258349412352.00 4835703278458516698824704.00 9671406556917033397649408.00 19342813113834066795298816.00
  Columns 85 through 88
 38685626227668133590597632.00 77371252455336267181195264.00 154742504910672534362390528.00 309485009821345068724781056.00
  Columns 89 through 92
 618970019642690137449562112.00 1237940039285380274899124224.00 2475880078570760549798248448.00 4951760157141521099596496896.00
  Columns 93 through 96
 9903520314283042199192993792.00 19807040628566084398385987584.00 39614081257132168796771975168.00 79228162514264337593543950336.00
  Columns 97 through 100
 158456325028528675187087900672.00 316912650057057350374175801344.00 633825300114114700748351602688.00 1267650600228229401496703205376.00
  Columns 101 through 104
 2535301200456458802993406410752.00 5070602400912917605986812821504.00 10141204801825835211973625643008.00 20282409603651670423947251286016.00
  Columns 105 through 108
 40564819207303340847894502572032.00 81129638414606681695789005144064.00 162259276829213363391578010288128.00 324518553658426726783156020576256.00
  Columns 109 through 112
 649037107316853453566312041152512.00 1298074214633706907132624082305024.00 2596148429267413814265248164610048.00 5192296858534827628530496329220096.00
  Columns 113 through 116
 10384593717069655257060992658440192.00 20769187434139310514121985316880384.00 41538374868278621028243970633760768.00 83076749736557242056487941267521536.00
  Columns 117 through 120
 166153499473114484112975882535043072.00 332306998946228968225951765070086144.00 664613997892457936451903530140172288.00 1329227995784915872903807060280344576.00
  Columns 121 through 124
 2658455991569831745807614120560689152.00 5316911983139663491615228241121378304.00 10633823966279326983230456482242756608.00 21267647932558653966460912964485513216.00
  Columns 125 through 128
 42535295865117307932921825928971026432.00 85070591730234615865843651857942052864.00 170141183460469231731687303715884105728.00 340282366920938463463374607431768211456.00
  Columns 129 through 132
 680564733841876926926749214863536422912.00 1361129467683753853853498429727072845824.00 2722258935367507707706996859454145691648.00 5444517870735015415413993718908291383296.00
  Columns 133 through 136
 10889035741470030830827987437816582766592.00 21778071482940061661655974875633165533184.00 43556142965880123323311949751266331066368.00 87112285931760246646623899502532662132736.00
  Columns 137 through 140
 174224571863520493293247799005065324265472.00 348449143727040986586495598010130648530944.00 696898287454081973172991196020261297061888.00 1393796574908163946345982392040522594123776.00
  Columns 141 through 144
 2787593149816327892691964784081045188247552.00 5575186299632655785383929568162090376495104.00 11150372599265311570767859136324180752990208.00 22300745198530623141535718272648361505980416.00
  Columns 145 through 148
 44601490397061246283071436545296723011960832.00 89202980794122492566142873090593446023921664.00 178405961588244985132285746181186892047843328.00 356811923176489970264571492362373784095686656.00
  Columns 149 through 152
 713623846352979940529142984724747568191373312.00 1427247692705959881058285969449495136382746624.00 2854495385411919762116571938898990272765493248.00 5708990770823839524233143877797980545530986496.00
  Columns 153 through 156
 11417981541647679048466287755595961091061972992.00 22835963083295358096932575511191922182123945984.00 45671926166590716193865151022383844364247891968.00 91343852333181432387730302044767688728495783936.00
  Columns 157 through 160
 182687704666362864775460604089535377456991567872.00 365375409332725729550921208179070754913983135744.00 730750818665451459101842416358141509827966271488.00 1461501637330902918203684832716283019655932542976.00
  Columns 161 through 164
 2923003274661805836407369665432566039311865085952.00 5846006549323611672814739330865132078623730171904.00 11692013098647223345629478661730264157247460343808.00 23384026197294446691258957323460528314494920687616.00
  Columns 165 through 168
 46768052394588893382517914646921056628989841375232.00 93536104789177786765035829293842113257979682750464.00 187072209578355573530071658587684226515959365500928.00 374144419156711147060143317175368453031918731001856.00
  Columns 169 through 172
 748288838313422294120286634350736906063837462003712.00 1496577676626844588240573268701473812127674924007424.00 2993155353253689176481146537402947624255349848014848.00 5986310706507378352962293074805895248510699696029696.00
  Columns 173 through 176
 11972621413014756705924586149611790497021399392059392.00 23945242826029513411849172299223580994042798784118784.00 47890485652059026823698344598447161988085597568237568.00 95780971304118053647396689196894323976171195136475136.00
  Columns 177 through 180
 191561942608236107294793378393788647952342390272950272.00 383123885216472214589586756787577295904684780545900544.00 766247770432944429179173513575154591809369561091801088.00 1532495540865888858358347027150309183618739122183602176.00
  Columns 181 through 184
 3064991081731777716716694054300618367237478244367204352.00 6129982163463555433433388108601236734474956488734408704.00 12259964326927110866866776217202473468949912977468817408.00 24519928653854221733733552434404946937899825954937634816.00
  Columns 185 through 188
 49039857307708443467467104868809893875799651909875269632.00 98079714615416886934934209737619787751599303819750539264.00 196159429230833773869868419475239575503198607639501078528.00 392318858461667547739736838950479151006397215279002157056.00
  Columns 189 through 192
 784637716923335095479473677900958302012794430558004314112.00 1569275433846670190958947355801916604025588861116008628224.00 3138550867693340381917894711603833208051177722232017256448.00 6277101735386680763835789423207666416102355444464034512896.00
  Columns 193 through 196
 12554203470773361527671578846415332832204710888928069025792.00 25108406941546723055343157692830665664409421777856138051584.00 50216813883093446110686315385661331328818843555712276103168.00 100433627766186892221372630771322662657637687111424552206336.00
  Columns 197 through 200
 200867255532373784442745261542645325315275374222849104412672.00 401734511064747568885490523085290650630550748445698208825344.00 803469022129495137770981046170581301261101496891396417650688.00 1606938044258990275541962092341162602522202993782792835301376.00
  Columns 201 through 204
 3213876088517980551083924184682325205044405987565585670602752.00 6427752177035961102167848369364650410088811975131171341205504.00 12855504354071922204335696738729300820177623950262342682411008.00 25711008708143844408671393477458601640355247900524685364822016.00
  Columns 205 through 208
 51422017416287688817342786954917203280710495801049370729644032.00 102844034832575377634685573909834406561420991602098741459288064.00 205688069665150755269371147819668813122841983204197482918576128.00 411376139330301510538742295639337626245683966408394965837152256.00
  Columns 209 through 212
 822752278660603021077484591278675252491367932816789931674304512.00 1645504557321206042154969182557350504982735865633579863348609024.00 3291009114642412084309938365114701009965471731267159726697218048.00 6582018229284824168619876730229402019930943462534319453394436096.00
  Columns 213 through 216
 13164036458569648337239753460458804039861886925068638906788872192.00 26328072917139296674479506920917608079723773850137277813577744384.00 52656145834278593348959013841835216159447547700274555627155488768.00 105312291668557186697918027683670432318895095400549111254310977536.00
  Columns 217 through 220
 210624583337114373395836055367340864637790190801098222508621955072.00 421249166674228746791672110734681729275580381602196445017243910144.00 842498333348457493583344221469363458551160763204392890034487820288.00 1684996666696914987166688442938726917102321526408785780068975640576.00
  Columns 221 through 224
 336999333339382997433337688587745383420464305281757156013795128...