# Challenge

Given a number x, output the first x powers of two, starting with 2¹ (2).

### Example

2   2 4
3   2 4 8
1   2
6   2 4 8 16 32 64


You may output numbers separated by non-numerical characters. You may not just output them mashed together like 248163264128.

# Rules

• In your code, you may only use the number 2. You may not use any other numbers, either as ASCII characters or numeric literals in any base.
• You may not use character literals as integers to bypass this rule.
• You may not use your language's built-in exponentiation function, operator, or similar. You must implement the exponent yourself.
• You may not use bit shifting operators.
• You may not use operations that are equivalent to bit shifting.
• Standard loopholes are disallowed.
• This is , shortest answer wins. However, it will not be selected.

## closed as unclear what you're asking by Sriotchilism O'Zaic, Downgoat, AdmBorkBork, Riley, RɪᴋᴇʀApr 20 '17 at 19:09

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• In my opinion this is the worst type of restricted source challenge. It is really impossible to verify whether or not a particular program contains a number other than 2 objectively. Each language becomes its own separate argument about what is and is not allowed. For restricted source challenges you should be able to write a computer program that can verify if a particular program obeys the rules. – Sriotchilism O'Zaic Apr 20 '17 at 18:36
• This is a Do X without Y challenge. I reccomend checking out things to avoid doing in challenges – Downgoat Apr 20 '17 at 18:42
• (This could have really benefitted from some time in the Sandbox ...) – AdmBorkBork Apr 20 '17 at 18:51
• @Mendeleev likely because it's a boring challenge. If it's at all interesting, you're sure to get either votes or feedback. And bad feedback is not being ignored, that's constructive criticism (idk if you've had any of that though). – Rɪᴋᴇʀ Apr 20 '17 at 19:12
• I can see loopholes in two of the restrictions without even spending any time to think about it. Predefined variables which by default hold numeric values but which aren't numeric literals bypass the restriction on using numbers; base conversion bypasses the restriction on exponentiation. – Peter Taylor Apr 20 '17 at 21:44

(takeiterate(*2)2)


Try it online!

3 bytes longer than the unrestricted:

f n=map(2^)[1..n]


## Alice, 16 bytes

t/O<\*2Hw&
k\i.@


Try it online!

### Explanation

This uses the w&...k looping technique explained in this answer.

t    Decrement the implicit zero on top of the stack to give -1 to initialise
the product for later.
/    Reflect to SE. Switch to Ordinal.
i    Read all input as a string.
Bounce off bottom boundary, move NE.
<    Set the horizontal component of the IP direction to west, i.e. move NW.
Bounce off top boundary, move SW.
i    Try reading more input. Just pushes an empty string.
Bounce off bottom boundary, move NW.
/    Reflect to W. Switch to Cardinal.
t    Implicitly discard the empty string and convert the actual input to its
numerical value N. Decrement it to get N-1.
IP wraps around to the last column.
&w   Repeat the following bit N times.
H    Take the absolute value of the top of the stack. This is only
relevant for the first iteration, because we initialised the product
2*   Double the current product.
\    Reflect to SW. Switch to Ordinal.
.    Duplicate the current product (also converts it to a string, but it
will be converted back by the H).
Bounce off bottom boundary, move NW.
O    Output the current product as a string with a trailing linefeed.
Bounce off top boundary, move SW.
\    Reflect to W. Switch to Cardinal.
k    End of loop.
IP wraps around to the last column.
@    Terminate the program.


# Cheddar, 26 bytes

n->2/2|>n=>n->[n]*n/(*)


Takes n as art generated range [1, n], maps (=>) It over [n]*n (array of n n times over multiplication)

No TIO link because cheddar on TIO is outdated.

# Brain-Flak, 44 bytes

(([{}]){}<(()())>){({}<((({})){})>()())}{}{}


Try it online!

Explanation:

#Push negative(input * 2)
(([{}]){}

#And push a 2 underneath it
<(()())>
)

#While True:
{

#Pop the top of the stack off
({}

#And double the number underneath it
<((({})){})>

#Then push the former top of the stack + 2
()())

#Endwhile
}

#Pop two elements, implicitly display stack
{}{}


## JavaScript (ES6), 35 bytes

x=>[...Array(x)].map(_=>p+=p,p=x/x)


Using no digits at all.

# Octave, 23 bytes

@(x)cumprod(~(2/2:x)+2)


Try it online!

Returns cumulative product of repeated 2s.

# Jelly, 5 4 bytes

2ṁ×\


Try it online!

### How it works

2ṁ×\  Main link. Argument: n

2ṁ    Mold; reshape [2] as [1, ..., n], generating an array of n 2's.
×\  Take the cumulative product.


# SOGL, 6 bytes

2.{t2*


Explanation:

2       push 2
.{     repeat input times
t     output
2*   multiply by two


## Ruby, 29 bytes

->n{b=2;n.times{puts b;b*=2}}


# Python 2, 31 bytes

n=2
exec"print n;n*=2;"*input()


Try it online!

This might be the shortest way to do it, restrictions or no. Compare

lambda n:[2<<i for i in range(n)]
# 33 bytes, ignoring restrictions


Try it online

# CJam, 11 bytes

2ri{_p2*}*;


Try it online!

## Batch, 80 bytes

@set/px=
@set/ap=2/2
@for /l %%i in (%p%,%p%,%x%)do @set/ap+=p&call echo %%p%%


Takes input on STDIN, since %1 would be illegal. Fully illegal version would only be 63 bytes:

@set/ap=1
@for /l %%i in (1,1,%1)do @set/ap+=p&call echo %%p%%