# Output endless powers of 2 [duplicate]

In any programming language, make a program that outputs infinite subsequent powers of two, starting at any power of two with finite integer exponent. There does not need to be a seperator between outputs.
Note: it only has to theoretically output infinite subequent powers of two given infinite integer size (so you can ignore any potential issues with floating-point).
Each power of two sufficently sized (greater than some value) must be theoretically be able to be outputted within a finite amount of time.
An example in js might look like this:

var num = 1;
while (true){
console.log(num);
num *= 2;
}

Remember, shortest wins

Standard Loopholes apply.

• Possible duplicate Commented May 29, 2023 at 20:43
• @Shaggy That counts incrementally. This counts by repeated doubling. Commented May 29, 2023 at 21:12
• Multiplying by 2 instead of adding 1 isn't a significant enough difference for me such that the majority of solutions for one aren't trivially modifiable to work for the the other. Commented May 29, 2023 at 21:31
• Given that the upvotes on my comment above would be sufficient to VTC this and that my Rockstar solution was automatically flagged as a duplicate of my solution to the dupe target, I'm afraid I'm going to have to swing my hammer here. Commented May 30, 2023 at 21:42
• Well, I solved this before I realized it was closed. Here's my 10 Piet-ASCII. Commented Jun 27, 2023 at 20:04

# Fortran (GFortran), 51 bytes

integer(kind=16)i;i=1
1 print*,2**i;i=i+1;goto1;end


Try it online!

Fortran's default integer max is 2147483647 (=2^31-1) but setting kind=16 extends the range up to 170141183460469231731687303715884105727 (=2^127-1)

# bc, 14 bytes

while(1)2^x++



Try it online!

# Arturo, 19 bytes

1whileø[*2print<=]


1         ; push 1 to the stack
whileø[   ; start infinite loop
<=    ; duplicate
print ; print
*2    ; double
]         ; end infinite loop(?)


# Nibbles, 3 bytes (6 nibbles)

.;2*

.;2*       # full program
.;2*@$# with implicit args added . # repeatedly apply (while results are unique) 2 # starting with 2 ; # (and save the 2 for later) * # multiply @ # saved value of 2$     #   by result-so-far


Alternative approach, also 3 bytes (6 nibbles):

.,~^2

.,~^2       # full program
.,~^2$# with implicit arg added . # map over , # list from 1.. ~ # infinity: ^2 # 2 to the power of$      #   each element in the list


# 05AB1E, 2 bytes

∞o


Try it online.

Explanation:

∞   # Infinite list of positive integers: [1,2,3,...]
o  # Take 2 to the power each value in the list
# (after which the infinite list is output implicitly as result)


# MathGolf, 4 bytes

îóo∟


Try it online.

Explanation:

   ∟  # Do-while true without popping:
ó    #  Take 2 to the power
î     #  the 1-based loop index
o   #  Print with trailing newline without popping


# Python, 24 bytes

-1 byte from @Sisyphus

a=1
while[print(a)]:a*=2


Attempt This Online!

# Python 2, 24 bytes

a=1
while 1:print a;a*=2


Attempt This Online!

• while[print(a)]:a*=2 Commented May 30, 2023 at 7:47

# Go, 32 bytes, to STDERR

func f(n int){println(n);f(n*2)}


Attempt This Online!

# Go, 45 bytes, to STDOUT

import."fmt"
func f(n int){Println(n);f(n*2)}


Attempt This Online!

# Knight, 13 bytes

;=a 1W=a*2aOa


Try it online!

# Alice, 11 bytes

.2~E/ O \h



Try it online!

The trailing newline is required

.             Duplicates the top of the stack, or two 0 if the stack is empty
2~           Pushes two on the stack, swap the top two items
E          Calculates 2^n, where n is the current iteration minus 1
/ O \     Prints the number
h    Increments the exponent