# Count up forever

Write a program that counts up forever, starting from one.

Rules:

• Your program must log to STDOUT or an acceptable alternative, if STDOUT is not available.
• Your program must be a full, runnable program, and not a function or snippet.
• Your program must output each number with a separating character in between (a newline, space, tab or comma), but this must be consistent for all numbers.
• You may print the numbers in decimal, in unary or in base 256 where each digit is represented by a byte value.
• Your program must count at least as far as 2128 (inclusive) without problems and without running out of memory on a reasonable desktop PC. In particular, this means if you're using unary, you cannot store a unary representation of the current number in memory.
• Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

• This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

### Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

• I'm not sure how to combine must output each number with a separating character in between with may print the numbers [...] in base 256. – Dennis Nov 14 '15 at 14:25
• For future challenges, may I recommend the sandbox such that all these details could be sorted out before people start posting answers? :) – Martin Ender Nov 14 '15 at 14:32
• @IlmariKaronen I interpret that as being a memory limit, not a time limit. possibly a time limit on per-increment. just set the counter to 2**128-10 and see how long it takes to take those last ten steps. – Sparr Nov 15 '15 at 7:41
• Can we have leading zeroes in the output? – Paŭlo Ebermann Nov 15 '15 at 11:43
• Ugh!!! I have an answer for TI-89 (56b), but I can't post b/c I'm new to the site and don't have Rep 10+! – gregsdennis Nov 15 '15 at 20:45

# Python 3, 24 bytes

i=1
while[print(i)]:i+=1

Try it online!

[print(i)] is a list containing 1 element, which is always truthy. Thus the loop is repeated infinitely.

# Braingolf, 15 bytes

V# R1[l!_v!@R>]

### Explanation:

V# R1[l!_v!@R>]
V               Creates new stack and switches to it
#<space>       Pushes 32 (ASCII value of a space) to stack
1           Push 1
[........] do-while loop. Will always run once, then checks if
first value in stack is 0 after each loop, if it is,
breaks out of the loop
l         Push current length of stack
!_       Print last item on stack without popping
v      Switch to next stack
!@    Print last item on stack as ASCII char without popping
>  Move last item to the start of the stack

• This answer appears to fail the requirement "Your program must count at least as far as 2^128 (inclusive) ... without running out of memory on a reasonable desktop PC. In particular, this means if you're using unary, you cannot store a unary representation of the current number in memory." – pppery Sep 30 '20 at 16:08

# Jelly, 3 bytes

‘Ṅß

Try it online!

‘Ṅß
‘      Increment
Ṅ     Print w/ linefeed
• Wait there was actually never a Jelly answer on this before yesterday...?? Wow. But nice, +1! :D – hyper-neutrino Jun 17 '17 at 1:57

# Pushy, 4 bytes

1$#h 1 % Push 1$      % While loop (see below):
#     %   Output last item
h    %   Increment last item

The while loop will keep running while the last value on the stack evaluates to true. Because all values except 0 are truthy in Pushy, this loop will never exit. The ; to end the loop is assumed by the interpreter.

This should eventually reach 2^128 as specified, because Pushy uses Python 3 (arbitrary sized) integers.

# 05AB1E, 1 byte

Try it online!

∞  # [1, 2, ..., ∞]
# implicit output

# Ace, 4 bytes (non - competing)

vIPO

Try it online!

This is a new language I am (was, :() working on.

• It's past August 2018. – pppery Sep 30 '20 at 14:55
• @ppery :( Yeah I was young and lost interest – RaviRavioli Feb 25 at 15:25

n=1
Do
Wscript.Echo n
n=n+1
Loop

# C#, 83 Bytes

using System;class C{static void Main(){double x=0;for(;;)Console.WriteLine(x++);}}

Un-golfed:

using System;
class C {
static void Main(){
double b=0;
for(;;)Console.WriteLine(b++);
}
}

Note: C#'s double type can store values up to approximately 1.79769313486232x10308.

• 9007199254740992 is the last integer to which you can increment safely that can be represented in a double. Try this code: 9007199254740992.0 == 9007199254740992.0 + 1 - Spoiler alert: it evaluates as true. – Theraot May 27 '17 at 15:03

## C++, 72 bytes

Different from the other C++ answer, as it only uses the std library.

### Golfed:

#include<iostream>
int main(){for(int c=0;c>=0;c++,std::cout<<c<<"\n");}

### Ungolfed:

#include<iostream>
int main(){
for(int c = 0; c >= 0; c++){
std::cout<<c<<"\n";
}
}
• Save one byte by deleting the space before for :) – Leaky Nun Apr 25 '16 at 14:14
• Does for(int c=0;c>=0;c++,std::cout<<c<<"\n"); work? – Leaky Nun Apr 25 '16 at 14:15
• @KennyLau Yes, indeed it does. – Michelfrancis Bustillos Apr 25 '16 at 14:37
• This is not valid, because it needs to be able to count to at least 2^128, and int is not going to be that big. – Esolanging Fruit Aug 17 '18 at 6:40

# Bash, 25 bytes, possibly invalid

while :;do echo -n 1;done

Try it online!

Outputs infinite 1s. In other words, outputs all numbers 1.. in unary, separated by 1 :^)

This is definitely dubious, but I see nothing in the rules or comments that disallows it. I also didn't see an existing submission that uses this gimmick.

This solution could be smaller in other languages, but we need bash in order to be able to output in unary. Since bash has no numbers, I feel it qualifies.

It could probably be smaller in bash too. Unfortunately, I don't know much bash.

• Your program must output each number with a separating character in between (a newline, space, tab or comma), but this must be consistent for all numbers. – Jo King Aug 23 '20 at 1:08
• Is that to say that it must be one of a newline, space, tab, or comma? I read those just as examples. I will ask the OP. – Quelklef Aug 23 '20 at 1:10
• I guess that would be okay, but the point of that rule is to make sure numbers can be deciphered non-ambiguously – Jo King Aug 23 '20 at 1:44
• Sure, my answer definitely violates the intentions of the rules. – Quelklef Aug 23 '20 at 4:33
• Dubious separators aside, bash does have numbers. In any case, the challenge specifies that unary output is permitted, so there's no point using bash just to have unary output. – Chris Sep 30 '20 at 18:17