71
\$\begingroup\$

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.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## 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

<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 63834; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 39069; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "//api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "//api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(42), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>

\$\endgroup\$
  • 29
    \$\begingroup\$ 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. \$\endgroup\$ – Dennis Nov 14 '15 at 14:25
  • 6
    \$\begingroup\$ For future challenges, may I recommend the sandbox such that all these details could be sorted out before people start posting answers? :) \$\endgroup\$ – Martin Ender Nov 14 '15 at 14:32
  • 3
    \$\begingroup\$ @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. \$\endgroup\$ – Sparr Nov 15 '15 at 7:41
  • 5
    \$\begingroup\$ Can we have leading zeroes in the output? \$\endgroup\$ – Paŭlo Ebermann Nov 15 '15 at 11:43
  • 4
    \$\begingroup\$ 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+! \$\endgroup\$ – gregsdennis Nov 15 '15 at 20:45

190 Answers 190

1
\$\begingroup\$

APL (Dyalog APL), 13 14 10 bytes

{1+⎕←⍵}⍣≡0

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Braingolf, 10 bytes

1[!_2+# @]

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Whitespace, 40 bytes

   

  
   	
	    
 	
 	   	 	 
	
  
 


Try it online!

Outputs numbers separated by newlines. Whitespace numbers are integers of arbitrary length however certain interpreters may impose their own limits due to the implementation language. As a counterexample, whitespace.pl theoretically should be able to output forever as Perl supports arbitrary length integers.

Explanation

(s - space, t - tab, n - newline)

sssn     # push 0 - stack: [0]
nssn     # label ''
ssstn    # push 1 - stack: [<n-1>, 1]
tsss     # pop and add the top two items, push result - stack: [<n>]
sns      # duplicate the top item - stack: [<n>, <n>]
tnst     # pop, print as num - stack: [<n>]
ssststsn # push 10 - stack: [<n>, 10]
tnss     # pop, print as char (LF) - stack: [<n>]
nsnn     # jump to label ''
\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), 74 69 chars

Output is binary.

for(r="1";;r=r.replace(/(?:(^1)|.)(?=1*$)/g,(m,f)=>f?10:m^1))alert(r)
\$\endgroup\$
  • \$\begingroup\$ The question says you have to start counting from 1, not 0. \$\endgroup\$ – kamoroso94 Oct 9 '17 at 1:34
  • \$\begingroup\$ @kamoroso94, not a problem. Fixed it. \$\endgroup\$ – Qwertiy Oct 9 '17 at 7:08
1
\$\begingroup\$

T-SQL, 47 Bytes

DECLARE @ NUMERIC(38)=1F:PRINT @ SET @+=1GOTO F

Unfortunately, it only goes up to 2^126...

\$\endgroup\$
1
\$\begingroup\$

Triangular, 15 10 9 bytes

-5 thanks to caird

\#iA.,/%<

Try it online!

Formatted:

   \
  # i
 A . ,
/ % < ÿ

Redirects/bounces only:

   \
  . .
 . . ,
/ . <

So the code i%A# is repeated infinitely.

  • i - increment top of stack
  • % - print top of stack as integer
  • A - push 10
  • # - print top of stack as ASCII and pop
\$\endgroup\$
  • \$\begingroup\$ 10 bytes \$\endgroup\$ – caird coinheringaahing Nov 14 '17 at 17:22
  • \$\begingroup\$ @cairdcoinheringaahing Thanks! Managed to get it down to 9. \$\endgroup\$ – MD XF Nov 14 '17 at 17:41
1
\$\begingroup\$

TI-BASIC (Z80), 152 bytes

Hex dump:

2a31323334353637383904aa003f2a3004aa013fd1313fdeaa013fbb2baa0104413f3104463fd1416c3040463fbb0caa012b412b31116a2a3904463f41713104413fd43fce463fcf3f2a313fd03fbb0caa002b3170bb2abb0caa012b4170312b3111112b313fce413fbb0caa012b312b411170723fd43fd3492b312bbb2baa0111714171b8463f72702a303fd43f7204aa013fd4

Token rendering:

"123456789→Str1
"0→Str2
While 1
Disp Str2
length(Str2→A
1→F
While A>0 and F
sub(Str2,A,1)="9→F
A-1→A
End
If F
Then
"1
Else
sub(Str1,1+expr(sub(Str2,A+1,1)),1
If A
sub(Str2,1,A)+Ans
End
For(I,1,length(Str2)-A-not(F
Ans+"0
End
Ans→Str2
End

Implements incrementing on string-based decimal arbitrary-precision nonnegative integers. I haven't put much effort into golfing this, since just working with strings in this language is already hard enough.

The program should work on the whole TI-83 through -84 series (tested on the TI-84 Plus SE).

Encoding

TI-BASIC code, like all text on the TI-8X, uses its own token-based encoding (see these token tables provided by a third party).

Output

Output is in decimal through Disp, which essentially prints a string on its own line. On the TI-83 through TI-84 Plus SE calculators, once the numbers get large enough that they no longer fit on the display they'll appear truncated with ellipses in the last column. This is by far the TI-BASIC output method closest to standard out.

\$\endgroup\$
1
\$\begingroup\$

AutoHotkey, 27 bytes

Based on Michelfrancis' answer: https://codegolf.stackexchange.com/a/78480/72779.

(Should I post this as a reply instead? Pretty new to this, but I don't have enough reputation to reply to other answers anyway.)

c=0         ; Colon-equal operator not required.       Saves one byte.
Loop{       ; Removed space between Loop and {.        Saves one byte.
c++         ; Shorter incremeting method, removed tab. Saves four bytes.
tooltip %c% ; Removed tab.                             Saves one byte.
}
\$\endgroup\$
  • \$\begingroup\$ Posting a separate answer is completely fine. Once you have enough rep to comment, you may prefer to leave the improvement as a suggestion instead, but it's ultimately up to you. \$\endgroup\$ – Martin Ender Jan 23 '18 at 9:08
1
\$\begingroup\$

Rail, 30 bytes

$'main'
/-uuo\
|     |
\o] [-/

Try it online!

Explanation:

$'main'    Is the beginning of every Rail program, and the train starts moving south-east from $.
/-uuo\     The train then hits '-' which makes it move east. 
|     |    It then hits 'u' which pushes the number of elements on the stack, before printing with 'o'.
\o] [-/    This simply pushes a space to the stack, and prints it. The '-' has to be there, so it starts moving west.

The movment of the train, is essentially just in a circle.
\$\endgroup\$
1
\$\begingroup\$

Pyt, 6 bytes

0`⁺ĐƤł

Try it online!

0   pushes zero
`   starts a while non-zero loop (but isn't checked until close loop)
⁺   increments x
Đ   Duplicates x
Ƥ   Prints with a separating newline
ł   go back to ` and loop till top is zero
\$\endgroup\$
1
\$\begingroup\$

Stax, 4 bytes

0W^Q

Run and debug it online

Added for completeness.

Explanation

0        Pushes 0
 W       Loop forever
  ^      Increment
   Q     Peek and print with newline
\$\endgroup\$
1
\$\begingroup\$

Flobnar, 15 bytes

 \@
+_
<.9,!
>:

Try it online!

Uses the -d flag in order to output in decimal. The separator between numbers is the tab character

\$\endgroup\$
1
\$\begingroup\$

Pip, 6 bytes

W1P++i

Try it online!

Straightforward; in pseudocode, this is

while(1)
 print(++i)

where i is preinitialized to 0.

\$\endgroup\$
1
\$\begingroup\$

Alchemist, 19 bytes

0a->Out__+Out_" "+_

Try it online!

Prints numbers separated by spaces.

Explanation:

0a->                 # While there are no a atoms (i.e. always)
    Out__            # Output the number of _ atoms
         +Out_" "    # Print a space
                 +_  # Add an _ atom to the environment
\$\endgroup\$
1
\$\begingroup\$

Runic Enchantments, 446 bytes

\DB͍R"000000000000000000000000000000000000001"$
.{ww;'''''''''''''''''''''''''''''''''''''''
.10{BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
a+'0000000000000000000000000000000000000000
kk0~111111111111111111111111111111111111111
$:{~+++++++++++++++++++++++++++++++++++++++
1'~}567890123456789012345678901234567890123
J://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.=? 000001111111112222222222333333333344444
/\/v\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Try it online!

This one took me a while. Runic is not set up to handle arbitrarily large values. The C# interpreter is limited by the fixed bit width of the value types involved, none of which are 128 bits wide and no language commands result in a BigInt being pushed to the stack.

So, instead, I used a string. But decomposing a string into that many characters (and then concatenating them back together again) is a nightmare (especially with that many digits as the instruction pointer starts to fizzle when its stack is too big--there are limited workarounds to that, but this setup works for actually arbitrarily large values, provided that the program is made bigger to accommodate; question specification only required up to 2128 which requires 39 digits; each additional power of 10 adds 10 bytes), so instead the storage is done inside the source code and updated with reflection. I also saw no clarification on whether or not leading 0s were allowed or not, but having them made things much easier.

Control flow

Image depicts fewer decimal digits for brevity as well as the Red/Yellow/Purple sections offset by 1, due to an old version of the code.

  • Cyan: Entry point and output. Reads a string value, pushes it to output, prints a newline, increases mana by 1 (reflection costs 1 mana; image is missing this command), and then enters the blue section via torodial edge wrapping.
  • Blue: Read character from the string, edge wrap to Green.
  • Green: push x position of the read character (in a consistent format, largely for convenience of the programmer), push 1,1 and Branch to position 1,1 (Red).
  • Red: rotate character to top of stack, add 1, convert to character, duplicate, compare with : ('9'+1 equals :). If true, go to Yellow. Else go to Purple.
  • Yellow: Toss out the Branch return coordinates, push a 0 (y coordinate for the write command), write the value, proceed to Cyan.
  • Purple: Toss out the top of the stack (the :), push a 0 (y coordinate for the write command), push a '0' character, write the 0, return to Branch entry (Salmon) using the modified form, which does not push return coordinates (so two giant rows of ~ aren't needed).
  • Salmon (was supposed to be Orange): Repeat steps Blue and Green on the next power of 10.

If it ever fills the entire string with 9s, the next loop would replace it all with 0s and hit the terminator ;. As the online interpreter has a built-in arbitrary maximum execution limit (not including TIO's external limits), this will never actually occur, but that's an implementation detail and not imposed by the language specification.

\$\endgroup\$
1
\$\begingroup\$

MathGolf, 5 4 bytes

Åîo▲

Try it online.

Thanks to @maxb for explaining how to do an infinite loop in MathGolf.

Explanation:

   ▲    # Do-while true by popping the value,
Å       # with two commands within the loop-body:
 î      #  Push the 1-indexed loop-index
  o     #  Print it with a trailing newline without popping

Note that just like in Python, a positive integer is considered truthy, which is why we print the loop-index without popping so the while(true) can continue.

\$\endgroup\$
1
\$\begingroup\$

Keg, 4 bytes

{!:.

Explanation

{    Forever:
 !   Push the length of the stack
  :. Print the number and repeat

Loop is implicitly ended

Try it online!

\$\endgroup\$
  • \$\begingroup\$ You can save a byte by dropping the closing } \$\endgroup\$ – Lyxal Jul 12 '19 at 22:44
  • \$\begingroup\$ using the most recent interpreter? \$\endgroup\$ – Lyxal Jul 13 '19 at 3:32
  • 1
    \$\begingroup\$ I was using an old interpreter... I updated my interpreter. \$\endgroup\$ – a'_' Jul 13 '19 at 4:08
1
\$\begingroup\$

tinylisp, 33 bytes

(d f(q(l(f(a(h l)1)(disp(h l
(f 1

Try it online!

This is a golf of DLosc's answer, but different enough I thought it would deserve its own answer.

The interpreter fills out )s at the end of a line.

(d f (q vars body)) define f to be (q vars body), this form indicates to tinylisp f is a function taking as arguments vars returning body. vars is l in case, so all the arguments to f get put into a list and passed to l (had v been parenthesised, like (n) in DLosc's answer, f would be defined to only take 1 argument n).

The complete body is (f(a(h l)1)(disp(h l))) (3 trailing )s filled by tinylisp). This calls the function f with the arguments (a(h l)1) and (disp(h l)), which when called will let f see them through l as a list containing both of these arguments. (a(h l)1) adds 1 to (h l), the head of l. This is the counter. The second argument is (disp(h l)) which displays (h l) the head of l (the counter), and returns (). This second argument never gets used but using disp here allows the f to print every cycle.

The loop is started by (f 1) which calls f with l as the list of all the arguments, i.e. (1), the head of which is the counter.

\$\endgroup\$
  • \$\begingroup\$ A variadic function! That's clever, I like it! \$\endgroup\$ – DLosc Dec 18 '19 at 20:42
1
\$\begingroup\$

05AB1E, 3 bytes

∞€,

Try it online!

tio.run truncates the input, but in theory this would count forever. Also on tio.run, there's a [ at the beginning, which I don't know how to get rid of.

Explanation

∞    # push infinite list ([1, 2, …, ∞])
 €   # pop a; apply next command for each in a
  ,  # pop a; print(a) (with newline)
\$\endgroup\$
  • \$\begingroup\$ You can get rid of the [ in the output by using the argument-flag --no-lazy. Has something to do with printing within a map with lazy-loading in Elixir, where 05AB1E is built in. But the --no-lazy will disable this lazy-loading, so you won't have this in the output. :) \$\endgroup\$ – Kevin Cruijssen Jan 3 at 8:54
  • \$\begingroup\$ @KevinCruijssen oh, thanks! does it still count with the [? \$\endgroup\$ – Sagittarius Jan 4 at 23:24
1
\$\begingroup\$

Python 3, 53 bytes

import itertools
for i in itertools.count(1):print(i)

Try it online!

Explanation

I prefer to avoid while loops in my code, therefore I decided to write the program.

import itertools                     # Pretty simple, import something
for i in itertools.count(1):         # Foreach in the infinite list from 1 to ∞
                            print(i) #     Print the current item
\$\endgroup\$
  • \$\begingroup\$ Wow, that's rude. What did while loops ever do to you to deserve such hate? :P \$\endgroup\$ – Lyxal Jan 5 at 3:08
  • \$\begingroup\$ Okay, that's better. Y'all know I was joking though? :P \$\endgroup\$ – Lyxal Jan 5 at 4:04
0
\$\begingroup\$

PowerShell, 19 14 Bytes

for(){$i++;$i}

Removed echo as per user recommendation

\$\endgroup\$
  • 3
    \$\begingroup\$ Is $i really going to have an inferred type which goes as far as 2^128? \$\endgroup\$ – Peter Taylor Nov 16 '15 at 19:38
  • \$\begingroup\$ @PeterTaylor I had no idea how big 2^128 was until this challenge was posted. @Chad Baxter for shortening output, you can leave off echo. \$\endgroup\$ – Booga Roo Nov 16 '15 at 21:14
  • \$\begingroup\$ Powershell is very good at making sure the memory space is large enough. If it won't fit in a 32 bit int, it will automatically convert it to a 64bit int...for anything higher it autoconcatenates \$\endgroup\$ – Chad Baxter Nov 16 '15 at 21:54
  • \$\begingroup\$ So technically it will only fill two Int64 to meet requirements...but it can go higher \$\endgroup\$ – Chad Baxter Nov 16 '15 at 21:57
  • 1
    \$\begingroup\$ Once you figure out the conversion to allow 2^128 (I'm not sure it's possible without using [bigint]), you can save a couple bytes by doing (++$i) instead of $i++;$i -- the prepending ++ ensures we start at 1, and enclosing in parens () will automatically output, since it's left on the pipeline alone. However, if you need [bigint], ignore this recommendation. \$\endgroup\$ – AdmBorkBork Nov 25 '15 at 14:15
0
\$\begingroup\$

Pylongolf2, 6 bytes

0>1+~<

Have a zero in the stack and continously add up to it.
I could give a more detailed explanation.

Pylongolf2, 20 bytes (bonus)

cn:A0>1+~_A@1=?t¿d<

Only works in beta 6, but this version asks for what number to count to.

\$\endgroup\$
0
\$\begingroup\$

PRINDEAL, 21

a c 
 i n 
 r 
 c
a r 
 p n 
 c 
 r

Preceds each number printed with n =, because it is not possible to print without such a prefix in PRINDEAL.

\$\endgroup\$
0
\$\begingroup\$

PostL Non-competing, 13 bytes

Non-competing since this language postdates the challenge, and it can't quite count up to 2128

1C_'\n'_1+1;>
1             Push 1 onto the stack
 C            Copy the top of the stack
  _           Pop the top of the stack and output it
   '\n'       Push a newline onto the stack
       _      Pop the newline and output it
        1+    Add 1 to the top of the stack (which is the current number)
          1;> Goto index 1
\$\endgroup\$
0
\$\begingroup\$

Pushy, 4 bytes

1$#h

Non-competing as the language postdates the challenge.

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.

\$\endgroup\$
0
\$\begingroup\$

PHP, 95 74 64 bytes

<?for($n=_;;print strrev($n))for($i=0;!$n[$i]=($n[++$i]+1)%10;);

or

<?for($n=_;;print strrev($n))while($i*=!$n[$i]=($n[++$i]+1)%10);

http://php.net/bc_installation: These functions are only available if PHP was configured with --enable-bcmath.
http://php.net/gmp_installation: In order to have these functions available, PHP must be compiled with GMP support by using the --with-gmp option.

So I just implemented bcadd ... sort of. Uses underscore as separator.

\$\endgroup\$
0
\$\begingroup\$

stacked, 12 bytes

[1+out]0 ani

Try it online!

This works as follows:

[1+out]0 ani
[     ]0 ani   in an interval of 0 seconds, do:
 1+            add 1 to the counter
   out         output it
\$\endgroup\$
0
\$\begingroup\$

REXX, 34 bytes

numeric digits 39
do #=0
say #
end

(If your interpreter is set to a suitably large default precision, you may skip the numeric digits line.)

\$\endgroup\$
0
\$\begingroup\$

VBA, 157 103 bytes

The Variant / Decimal data type in VBA only allows up to 29 digits of precision. 2^128 is 39 digits long so we have to smoosh two variables together. Variant is the default for any undeclared variable so that's easy. Every time the right-hand side (a) rolls over, set it back to 0 and iterate the left-hand side (b) by 1. To handle leading zeros, we set the format to be 28 digits long the first time that a rolls over. This has a smaller max than the string method but it's well above 2^128.

Sub c()
Do
a=a+1
If a=10^28Then b=b+1:a=0:f=Replace(Space(28)," ",0)
Debug.?b &Format(a,f)
Loop
End Sub

Once it's formatted for humans, it looks like this:

Sub c()
    Do
        a = a + 1
        If a = 10 ^ 28 Then b = b + 1: a = 0: f = Replace(Space(28), " ", 0)
        Debug.Print b & Format(a, f)
    Loop
End Sub

Previous method using strings:
It starts with the right-most character, converts it to a number, and then keeps moving left until the result is less than 10.

Sub d()
s="1"
Do
Debug.?s
For i=Len(s)To 1Step -1
c=Val(Right(s,1))+1
s=Left(s,i-1)
If c<10Then Exit For
If i-1Then r=r &"0"
Next
s=s &c &r
r=""
Loop
End Sub
\$\endgroup\$
  • \$\begingroup\$ I am curious to see if there may be a LongLong (64 bit int) data type solution for vba and this problem - though admittedly I cannot think of one at this time \$\endgroup\$ – Taylor Scott Mar 31 '17 at 7:50
  • \$\begingroup\$ @TaylorScott You were right, there totally was. I had thought it would be too awkward to squish them together but it ended up being shorter. \$\endgroup\$ – Engineer Toast Mar 31 '17 at 14:24
0
\$\begingroup\$

QBIC, 8 bytes

{n=n+1?n

Explanation:

{       Start an infinite loop
n=n+1   Increment n (starts at 0)
?n      PRINT n
        Loop closed implicitly

Runs better tan expected. QBIC, when run in QBasic 4.5 on DOSBOX handles numbers up to and including 2^128 quite well, but it has a tendency to use scientific notation for the bigger numbers.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.