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

Solution 174384

Submitted on 7 Dec 2012 by Aurelien Queffurust

Correct

33Size
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
 
%%
assert(nextpowb(2,126) == 7)
exposant =
     1
y =
     2
exposant =
     2
y =
     4
exposant =
     3
y =
     8
exposant =
     4
y =
    16
exposant =
     5
y =
    32
exposant =
     6
y =
    64
exposant =
     7
y =
   128
2
Pass
 
%%
assert(nextpowb(3,6560) == 8)
exposant =
     1
y =
     3
exposant =
     2
y =
     9
exposant =
     3
y =
    27
exposant =
     4
y =
    81
exposant =
     5
y =
   243
exposant =
     6
y =
   729
exposant =
     7
y =
        2187
exposant =
     8
y =
        6561
3
Pass
 
%%
assert(nextpowb(4,262141) == 9)
exposant =
     1
y =
     4
exposant =
     2
y =
    16
exposant =
     3
y =
    64
exposant =
     4
y =
   256
exposant =
     5
y =
        1024
exposant =
     6
y =
        4096
exposant =
     7
y =
       16384
exposant =
     8
y =
       65536
exposant =
     9
y =
      262144
4
Pass
 
%%
assert(nextpowb(5,21) == 2)
exposant =
     1
y =
     5
exposant =
     2
y =
    25
5
Pass
 
%%
assert(nextpowb(6,1294) == 4)
exposant =
     1
y =
     6
exposant =
     2
y =
    36
exposant =
     3
y =
   216
exposant =
     4
y =
        1296
6
Pass
 
%%
assert(nextpowb(7,5) == 1)
exposant =
     1
y =
     7
7
Pass
 
%%
assert(nextpowb(8,134217726) == 9)
exposant =
     1
y =
     8
exposant =
     2
y =
    64
exposant =
     3
y =
   512
exposant =
     4
y =
        4096
exposant =
     5
y =
       32768
exposant =
     6
y =
      262144
exposant =
     7
y =
     2097152
exposant =
     8
y =
    16777216
exposant =
     9
y =
   134217728
8
Pass
 
%%
assert(nextpowb(9,4782966) == 7)
exposant =
     1
y =
     9
exposant =
     2
y =
    81
exposant =
     3
y =
   729
exposant =
     4
y =
        6561
exposant =
     5
y =
       59049
exposant =
     6
y =
      531441
exposant =
     7
y =
     4782969
9
Pass
 
%%
assert(nextpowb(10,99993) == 5)
exposant =
     1
y =
    10
exposant =
     2
y =
   100
exposant =
     3
y =
        1000
exposant =
     4
y =
       10000
exposant =
     5
y =
      100000
10
Pass
 
%%
assert(nextpowb(11,1771559) == 6)
exposant =
     1
y =
    11
exposant =
     2
y =
   121
exposant =
     3
y =
        1331
exposant =
     4
y =
       14641
exposant =
     5
y =
      161051
exposant =
     6
y =
     1771561
11
Pass
 
%%
assert(nextpowb(12,429981693) == 8)
exposant =
     1
y =
    12
exposant =
     2
y =
   144
exposant =
     3
y =
        1728
exposant =
     4
y =
       20736
exposant =
     5
y =
      248832
exposant =
     6
y =
     2985984
exposant =
     7
y =
    35831808
exposant =
     8
y =
   429981696
12
Pass
 
%%
assert(nextpowb(13,2194) == 3)
exposant =
     1
y =
    13
exposant =
     2
y =
   169
exposant =
     3
y =
        2197
13
Pass
 
%%
assert(nextpowb(14,537814) == 5)
exposant =
     1
y =
    14
exposant =
     2
y =
   196
exposant =
     3
y =
        2744
exposant =
     4
y =
       38416
exposant =
     5
y =
      537824
14
Pass
 
%%
assert(nextpowb(15,2562890613) == 8)
exposant =
     1
y =
    15
exposant =
     2
y =
   225
exposant =
     3
y =
        3375
exposant =
     4
y =
       50625
exposant =
     5
y =
      759375
exposant =
     6
y =
    11390625
exposant =
     7
y =
   170859375
exposant =
     8
y =
   2.5629e+09
15
Pass
 
%%
assert(nextpowb(16,249) == 2)
exposant =
     1
y =
    16
exposant =
     2
y =
   256
16
Pass
 
%%
assert(nextpowb(17,2015993900438) == 10)
exposant =
     1
y =
    17
exposant =
     2
y =
   289
exposant =
     3
y =
        4913
exposant =
     4
y =
       83521
exposant =
     5
y =
     1419857
exposant =
     6
y =
    24137569
exposant =
     7
y =
   410338673
exposant =
     8
y =
   6.9758e+09
exposant =
     9
y =
   1.1859e+11
exposant =
    10
y =
   2.0160e+12
17
Pass
 
%%
assert(nextpowb(18,3570467226613) == 10)
exposant =
     1
y =
    18
exposant =
     2
y =
   324
exposant =
     3
y =
        5832
exposant =
     4
y =
      104976
exposant =
     5
y =
     1889568
exposant =
     6
y =
    34012224
exposant =
     7
y =
   612220032
exposant =
     8
y =
   1.1020e+10
exposant =
     9
y =
   1.9836e+11
exposant =
    10
y =
   3.5705e+12
18
Pass
 
%%
assert(nextpowb(19,6131066257790) == 10)
exposant =
     1
y =
    19
exposant =
     2
y =
   361
exposant =
     3
y =
        6859
exposant =
     4
y =
      130321
exposant =
     5
y =
     2476099
exposant =
     6
y =
    47045881
exposant =
     7
y =
   893871739
exposant =
     8
y =
   1.6984e+10
exposant =
     9
y =
   3.2269e+11
exposant =
    10
y =
   6.1311e+12
19
Pass
 
%%
assert(nextpowb(20,3199997) == 5)
exposant =
     1
y =
    20
exposant =
     2
y =
   400
exposant =
     3
y =
        8000
exposant =
     4
y =
      160000
exposant =
     5
y =
     3200000
20
Pass
 
%%
assert(nextpowb(21,85766100) == 6)
exposant =
     1
y =
    21
exposant =
     2
y =
   441
exposant =
     3
y =
        9261
exposant =
     4
y =
      194481
exposant =
     5
y =
     4084101
exposant =
     6
y =
    85766121
21
Pass
 
%%
assert(nextpowb(22,467) == 2)
exposant =
     1
y =
    22
exposant =
     2
y =
   484
22
Pass
 
%%
assert(nextpowb(23,519) == 2)
exposant =
     1
y =
    23
exposant =
     2
y =
   529
23
Pass
 
%%
assert(nextpowb(24,2641807540202) == 9)
exposant =
     1
y =
    24
exposant =
     2
y =
   576
exposant =
     3
y =
       13824
exposant =
     4
y =
      331776
exposant =
     5
y =
     7962624
exposant =
     6
y =
   191102976
exposant =
     7
y =
   4.5865e+09
exposant =
     8
y =
   1.1008e+11
exposant =
     9
y =
   2.6418e+12
24
Pass
 
%%
assert(nextpowb(25,95367431640600) == 10)
exposant =
     1
y =
    25
exposant =
     2
y =
   625
exposant =
     3
y =
       15625
exposant =
     4
y =
      390625
exposant =
     5
y =
     9765625
exposant =
     6
y =
   244140625
exposant =
     7
y =
   6.1035e+09
exposant =
     8
y =
   1.5259e+11
exposant =
     9
y =
   3.8147e+12
exposant =
    10
y =
   9.5367e+13