70
\$\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

184 Answers 184

2
\$\begingroup\$

Python 2 VM Opcodes, 14 bytes?

LOAD_CONST               0
LOAD_CONST               1
INPLACE_ADD
DUP_TOP
PRINT_ITEM
JUMP_ABSOLUTE            2

I'm not sure how to score this, the compiled code is 12 bytes of vm code but there are also the constants, which would be unscored. Each constant can fit in a single bit but I'll count them as 1 byte each for now.

The compiled .pyc file is 106 bytes long(!) and the raw text is 111 bytes long.

I will probably just write a short script that just takes python opcodes and runs them properly (A bit like Pyth but much more low level).

Overall, it's a very simple program. It loads 0 and 1 onto the stack and adds them. This removes both from the stack and leaves it with the result. It then duplicates the stack and prints the value of the first item, removing it from the stack. It then goes to line 2.

.pyc file (hexdump)

03 F3 0D 0A DB 5B 47 56 63 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 73 0C 00 00 00 64 01 00 64 02 00 37 04 47 71 03 00 28 03 00 00 00 4E 69 00 00 00 00 69 01 00 00 00 28 00 00 00 00 28 00 00 00 00 28 00 00 00 00 28 00 00 00 00 74 09 00 00 00 70 79 6B 65 5F 63 6F 64 65 52 00 00 00 00 01 00 00 00 74 00 00 00 00
\$\endgroup\$
2
\$\begingroup\$

Rotor, 7 bytes

1{1+}|

There's an unprintable again, hexdump:

0000000: 317b 1b31 2b7d 7c                      1{.1+}|

ew 7 bytes

\$\endgroup\$
2
\$\begingroup\$

Kotlin, 102 bytes

import java.math.BigInteger.*fun main(a:Array<String>){var i=ZERO;while(1>0){i=i.add(ONE);println(i)}}

Based on SuperJedi224's Java answer.

\$\endgroup\$
2
\$\begingroup\$

Acc!, 64 65 bytes

Also works in Acc!!.

Count q while 1 {
Count x while q-x+1 {
Write 7
}
Write 9
}

This prints the numbers out in unary using Bell characters seperated by tabs. If I have to use a more standard character, that would make the program 66 bytes.

The Acc! interpreter provided in the linked answer translates Acc! to Python, which does support arbritrary-precision integers.

\$\endgroup\$
2
\$\begingroup\$

GolfScript, 9 bytes

1{.p).}do

1      # push 1
{      # loop
  .p   # duplicate, output
  ).   # increment, duplicate
}do    # while non-zero
\$\endgroup\$
2
\$\begingroup\$

Win32 x86 Machine Code (PE32 Executable), 933 bytes

This implements a virtual datatype using a lookup table (aka array). The challenge requests support for 2^128 which is 39 decimal digits. By accident, this solution supports 38+N digit numbers, where N is the width of word (i.e. two bytes). After that, the behavior is undefined. You might notice a whole lot of too simple or too redundant code in the assembly below, but this is intended, because the compression algorithm optimizes this.

For example,

mov EAX, 0
mov dword [@@DATA+164], EAX

is two bytes shorter than

mov dword [@@DATA+164], 0

Also: I though of using the C runtime library (MSVCRT) to convert numbers to strings, but this is a DIY approach, so this solution contains it's own method of converting numbers to strings. Without this, the byte count would be 800-ish. Keep in mind that the PE header and decompression take up about 697 bytes :). Also, this is Win32 code (fully debugged, shouldn't produce any errors and spawns a clean console context to run in), it is not "just using Interrupts", so this contains it's own string printing method.

I've used MEW11SE to crunch the executable, because MEW's LZMA-E9 routine beats UPX, mpress, kkrunchy etc. 9.9 out of 10 times by far. I could have used nasm and crinkler, but I hate both of them. The assembly below is fasm.

Here's a binary (compressed) - Here's another binary (uncompressed)

Disclaimer: The compressed binary will probably set your PC on fire if you happen to have an AV installed.

Assembly

; minxomat

; Link as CUI subsystem
format PE CONSOLE
section ".code" code readable executable

; Convert single digit unsigned word to null-terminated char
makestr:
  push EBP
  mov EBP, ESP
  sub ESP, 12
  mov EAX, @@TEXT+0
  mov dword [EBP-4], EAX
  mov EAX, @@TEXT+3
  mov dword [EBP-8], EAX
  mov EAX, 0
  mov dword [EBP-12], EAX
  mov EAX, dword [EBP+8]
  add EAX, dword [EBP-8]
  mov AL, byte [EAX+0]
  mov EBX, dword [EBP-12]
  add EBX, dword [EBP-4]
  mov byte [EBX+0], AL
  mov AL, 0
  push EAX
  mov EAX, dword [EBP-12]
  add EAX, 1
  add EAX, dword [EBP-4]
  pop EBX
  mov byte [EAX+0], BL
  mov EAX, dword [EBP-4]
  mov ESP, EBP
  pop EBP
ret 4

; Ouput null-term'ed string at this pointer to console
printme:
  push EBP
  mov EBP, ESP
  sub ESP, 4
  mov EAX, 0
  mov dword [EBP-4], EAX

  addone:
    mov EAX, dword [EBP-4]
    add EAX, dword [EBP+8]
    mov AL, byte [EAX+0]
    cmp AL, 0
    je fwd
    inc dword [EBP-4]
    jmp addone

  fwd:
    xor EAX, EAX
    push EAX
    lea EAX, [EBP-4]
    push EAX
    mov EAX, dword [EBP-4]
    push EAX
    mov EAX, dword [EBP+8]
    push EAX
    mov EAX, 4294967285
    push EAX
    call [@10024]
    push EAX
    call [@10025]
    mov ESP, EBP
    pop EBP
ret 4

; Entry point.
main:
  ; Print initial zero
  push EBP
  mov EBP, ESP
  mov EAX, @@TEXT+14
  push EAX
  call printme

  @10007:
    mov EAX, 1
    mov dword [@@DATA+160], EAX
    mov dword [@@DATA+164], EAX
    mov EAX, 38
    mov dword [@@DATA+156], EAX

  @10008:
    mov EAX, dword [@@DATA+156]
    cmp EAX, 0
    jle @10016

  @10009:
    mov EAX, dword [@@DATA+156]
    shl EAX, 2
    mov EAX, dword [@@DATA+EAX+0]
    mov EBX, dword [@@DATA+160]
    add EAX, EBX
    mov EBX, dword [@@DATA+156]
    shl EBX, 2
    mov dword [@@DATA+EBX+0], EAX
    mov EAX, dword [@@DATA+156]
    shl EAX, 2
    mov EAX, dword [@@DATA+EAX+0]
    cmp EAX, 9
    jle @10011

  @10010:
    mov EAX, 0
    mov EBX, dword [@@DATA+156]
    shl EBX, 2
    mov dword [@@DATA+EBX+0], EAX
    mov EAX, 1
    mov dword [@@DATA+160], EAX
    jmp @10014

  @10011:
    mov EAX, 0
    mov dword [@@DATA+160], EAX

  @10014:
    dec dword [@@DATA+156]
    jmp @10008

  @10016:
    mov EAX, dword [@@DATA+156]
    cmp EAX, 39
    jge @10022

  @10017:
    mov EAX, dword [@@DATA+156]
    shl EAX, 2
    mov EAX, dword [@@DATA+EAX+0]
    cmp EAX, 0
    jg @10019

  @10018:
    mov EAX, dword [@@DATA+164]
    cmp EAX, 0
    jne @10021

  @10019:
    mov EAX, dword [@@DATA+156]
    shl EAX, 2
    mov EAX, dword [@@DATA+EAX+0]
    push EAX
    call makestr
    push EAX
    call printme
    mov EAX, 0
    mov dword [@@DATA+164], EAX

  @10021:
    inc dword [@@DATA+156]
    jmp @10016

  @10022:
    mov EAX, @@TEXT+17
    push EAX
    call printme
    jmp @10007

section ".data" data readable writeable

@@TEXT db "00", 0
       db "0123456789", 0
       db "0", 10, 0
       db 10, 0

@@DATA rb 168

section ".idata" import data readable writeable

dd 0, 0, 0, RVA @10026, RVA @10024
dd 0, 0, 0, 0, 0

@10024 dd RVA @10027
@10025 dd RVA @10028
       dd 0

@10026: db "KERNEL32.DLL", 0

@10027: dw 0
        db "GetStdHandle", 0
@10028: dw 0
        db "WriteFile", 0

section ".reloc" fixups data readable discardable
entry main

Hexdump

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000  4D 5A 6B 65 72 6E 65 6C 33 32 2E 64 6C 6C 00 00  MZkernel32.dll..
00000010  50 45 00 00 4C 01 02 00 00 00 00 00 00 00 00 00  PE..L...........
00000020  00 00 00 00 E0 00 0F 01 0B 01 00 00 00 02 00 00  ....à...........
00000030  00 00 00 00 00 00 00 00 95 51 00 00 10 00 00 00  ........•Q......
00000040  00 10 00 00 00 00 40 00 00 10 00 00 00 02 00 00  ......@.........
00000050  04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00  ................
00000060  00 60 00 00 00 02 00 00 00 00 00 00 03 00 00 00  .`..............
00000070  00 10 00 00 00 10 00 00 00 00 01 00 00 00 00 00  ................
00000080  00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00  ................
00000090  91 51 00 00 14 00 00 00 00 00 00 00 00 00 00 00  ‘Q..............
000000A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000C0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000100  00 00 00 00 00 00 00 00 4D 45 57 00 46 12 D2 C3  ........MEW.F.ÒÃ
00000110  00 40 00 00 00 10 00 00 00 00 00 00 00 00 00 00  .@..............
00000120  00 00 00 00 00 00 00 00 00 00 00 00 E0 00 00 C0  ............à..À
00000130  02 D2 75 DB 8A 16 EB D4 00 10 00 00 00 50 00 00  .ÒuÛŠ.ëÔ.....P..
00000140  A5 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00  ¥...............
00000150  00 00 00 00 E0 00 00 C0 BE 1C 50 40 00 8B DE AD  ....à..À¾.P@.‹Þ.
00000160  AD 50 AD 97 B2 80 A4 B6 80 FF 13 73 F9 33 C9 FF  .P.—²€¤¶€ÿ.sù3Éÿ
00000170  13 73 16 33 C0 FF 13 73 21 B6 80 41 B0 10 FF 13  .s.3Àÿ.s!¶€A°.ÿ.
00000180  12 C0 73 FA 75 3E AA EB E0 E8 72 4E 00 00 02 F6  .Àsúu>ªëàèrN...ö
00000190  83 D9 01 75 0E FF 53 FC EB 26 AC D1 E8 74 2F 13  ƒÙ.u.ÿSüë&¬Ñèt/.
000001A0  C9 EB 1A 91 48 C1 E0 08 AC FF 53 FC 3D 00 7D 00  Éë.‘HÁà.¬ÿSü=.}.
000001B0  00 73 0A 80 FC 05 73 06 83 F8 7F 77 02 41 41 95  .s.€ü.s.ƒø.w.AA•
000001C0  8B C5 B6 00 56 8B F7 2B F0 F3 A4 5E EB 9B AD 85  ‹Å¶.V‹÷+ðó¤^ë›.…
000001D0  C0 75 90 AD 96 AD 97 56 AC 3C 00 75 FB FF 53 F0  Àu..–.—V¬<.uûÿSð
000001E0  95 56 AD 0F C8 40 59 74 EC 79 07 AC 3C 00 75 FB  •V..È@Ytìy.¬<.uû
000001F0  91 40 50 55 FF 53 F4 AB 75 E7 C3 00 00 00 00 00  ‘@PUÿSô«uçÃ.....
00000200  33 C9 41 FF 13 13 C9 FF 13 72 F8 C3 66 51 00 00  3ÉAÿ..Éÿ.røÃfQ..
00000210  73 51 00 00 00 00 00 00 00 50 40 00 30 01 40 00  sQ.......P@.0.@.
00000220  8D 10 40 00 00 10 40 00 55 03 89 E5 83 EC 0C B8  ..@...@.U.‰åƒì.¸
00000230  81 20 40 C3 D1 45 FC E1 03 53 08 F8 70 20 E1 11  . @ÃÑEüá.S.øp á.
00000240  F4 8B EC 08 03 CE 1C 8A 1E 1E 5D FC 73 3E FC 88  ô‹ì..Î.Š..]üs>üˆ
00000250  38 B0 37 50 26 B1 83 C0 01 BF 2C 3F 5B B7 18 18  8°7P&±ƒÀ.¿,?[·..
00000260  60 89 EC 5D C2 70 04 AB 46 BD 33 36 FC 66 2F 40  `‰ì]Âp.«F½36üf/@
00000270  08 6C 70 3C 18 74 05 FF 18 EB EF 0D 31 C0 50 8D  .lp<.t.ÿ.ëï.1ÀP.
00000280  10 A2 76 04 7C 08 1B B8 F5 FF 02 F7 41 15 28 30  .¢v.|..¸õÿ.÷A.(0
00000290  B2 DA 0F 2C 28 47 E2 B8 0E A1 82 50 E8 AB BD 45  ²Ú.,(Gâ¸.¡‚P諽E
000002A0  B1 01 9F A3 B3 BA 21 B7 B7 0B F5 26 08 0F AF 94  ±.Ÿ£³º!··.õ&..¯”
000002B0  A1 05 1C 83 F8 0A 7E 6A 0A 80 C1 E0 02 8B 80 13  ¡..ƒø.~j.€Áà.‹€.
000002C0  DD 13 94 1D 2D 1A 01 D8 10 20 17 E3 02 89 83 84  Ý.”.-..Ø. .ã.‰ƒ„
000002D0  8D 25 31 70 09 7E DE 9A AA 36 27 85 6F 0D EB 0A  .%1p.~Þšª6'…o.ë.
000002E0  40 18 0C FF 50 0D 25 EB 53 8C 74 0A 27 7D 49 4F  @..ÿP.%ëSŒt.'}IO
000002F0  F3 80 7F 0A A1 52 B7 0A 15 75 24 1D A4 04 C8 9D  ó€..¡R·..u$.¤.È.
00000300  FE 19 0C DD 14 22 53 B7 11 05 0C AD 2A B8 11 23  þ..Ý."S·....*¸.#
00000310  44 C0 E9 55 10 F0 80 00 00 20 40 00 30 E3 C3 98  DÀéU.ð€.. @.0ãØ
00000320  31 32 33 03 34 35 36 37 38 39 38 16 0A 72 C0 00  123.4567898..rÀ.
00000330  D1 4F 40 00 28 38 30 40 07 4B 45 52 4E 30 4C 33  ÑO@.(80@.KERN0L3
00000340  32 2E 75 44 ED C0 80 47 1C 65 74 53 83 64 48 61  2.uDíÀ€G.etSƒdHa
00000350  6E A3 6C D6 1C 1F 57 72 69 FB BA 46 51 0B 80 00  n£lÖ..WriûºFQ.€.
00000360  00 00 00 00 D1 4F 40 00 4C 6F 61 64 4C 69 62 72  ....ÑO@.LoadLibr
00000370  61 72 79 41 00 47 65 74 50 72 6F 63 41 64 64 72  aryA.GetProcAddr
00000380  65 73 73 00 00 00 00 00 00 00 00 00 00 00 00 00  ess.............
00000390  00 0C 50 00 00 E9 BE AF FF FF 00 00 00 02 00 00  ..P..龯ÿÿ......
000003A0  00 0C 50 00 00                                   ..P..
\$\endgroup\$
  • \$\begingroup\$ Can't you save header by using a .com file? \$\endgroup\$ – TWiStErRob Nov 15 '15 at 9:26
  • \$\begingroup\$ @TWiStErRob That would be no fun. (Plus no one would be able to run it). \$\endgroup\$ – mınxomaτ Nov 15 '15 at 10:07
  • 1
    \$\begingroup\$ I thought Dosbox or a VM with WinXPx86 downwards would do it. \$\endgroup\$ – TWiStErRob Nov 15 '15 at 10:12
  • \$\begingroup\$ @mınxomaτ - you should take a look at clinkster unless you're already familiar with it. It's a 4k synth - the output of a 2m38s Renoise track built into an exe alongside the synth, using crinkler is 2,838 bytes. It's 3 times the size of your program, grabs 100MB of mem and thrashes 1 core of an i7 3537u for 23 seconds before the music starts. It's pretty impressive! Right up there with "Farbrausch - fr-041: debris". (Also small point - you've mistakenly said that the word size of a 32 bit program is 16 bits) Here's Clinkster's page at Pouet: pouet.net/prod.php?which=61592 \$\endgroup\$ – enhzflep Nov 15 '15 at 12:26
2
\$\begingroup\$

Ceylon (on JVM), 92 87 78 bytes

(The Big integer type Whole which is used here does only exist on the JVM, not when compiling for JavaScript.)

This is the third improvement (78 bytes):

import ceylon.math.whole{o=one}shared void run(){loop(o)(o.plus).each(print);}

The loop function is a functional version of the while-statement – it creates a stream from a starting value (one) and a function (one.plus), applying the function to the previous value until it returns finished (which our function never does, so it becomes an infinite stream). On each element, print(...) is applied.

An Integer version which goes only until just under 2^63 (on JVM) or 2^31 (on JS), then will wrap around to negatives (JVM) or stall (for JS), for 48 bytes:

shared void run(){loop(1)(1.plus).each(print);}


Second version (87):

import ceylon.math.whole{o=one}shared void run(){{o}.cycled.scan(o)(plus).each(print);}

That builds first an infinite stream of ones, and then creates a scanning stream, which calculates the partial sums (which then are each printed).


Original version (92):

A straight-forward n++-loop, with a big integer type (called Whole in Ceylon, but the type name is not actually used in this program, just the name of the 1):

import ceylon.math.whole{o=one}shared void run(){variable value n=o;while(0<1){print(n++);}}


This one is shorter (83), counting from 1 to 2^65536, but it doesn't actually work:

import ceylon.math.whole{o=one,t=two}shared void run(){(o..t^t^t^t^t).each(print);}

The problem is that the range notation x..y will call span(x,y), which will call x.offset(y) to get the offset between them, and this method is defined to return an Integer – which will overflow here, as the difference is much too large to fit into an Integer (which was the whole point of using Whole here).

\$\endgroup\$
2
\$\begingroup\$

C + gcc extensions, 77 bytes

char c[]={[0 ...49]=48};main(a){for(;;puts(c))for(a=49;++c[a]>57;c[a--]=48);}
\$\endgroup\$
2
\$\begingroup\$

Common Lisp, 30 bytes

(do((i 0))(())(print(incf i)))

or

(do((x 0(1+ x)))(())(print x))

This should get to 2128 without a problem, since Common Lisp has bignums. E.g.:

CL-USER> (print (expt 2 128))
; 340282366920938463463374607431768211456
\$\endgroup\$
2
\$\begingroup\$

JavaScript, 80 bytes

r=t=>{t=a.pop()||0;if(++t>9){r();t=0}a.push(t)};for(a=[1];;r())alert(a.join(''))

To test at 2^128 in console, for 1000 cycles;

r=t=>{t=a.pop()||0;if(++t>9){r();t=0}a.push(t)};for(x=1,a=[3,4,0,2,8,2,3,6,6,9,2,0,9,3,8,4,6,3,4,6,3,3,7,4,6,0,7,4,3,1,7,6,8,2,1,1,4,5,6];x<=1000;r(),x++)console.log(a.join(''))

And to test all 9s for 2 cycles;

r=t=>{t=a.pop()||0;if(++t>9){r();t=0}a.push(t)};for(x=1,a=[9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9];x<=2;r(),x++)console.log(a.join(''))

My original idea was to actually use objects, but the array idea turned out to be super small. Mine should be the smallest JavaScript one at the moment

Object Oriented: 107 bytes

function d(p){var x=0,s="";this.o=q=>{return++x>9&&(x=0,p=p||new d,s=p.o()),s+x}}for(c=new d;;)alert(c.o())
\$\endgroup\$
  • \$\begingroup\$ How does this work? Strings? \$\endgroup\$ – clamchowder314 Apr 1 '16 at 12:18
  • \$\begingroup\$ Also, be sure to avoid the maximum call stack size, which is 19299. \$\endgroup\$ – clamchowder314 Apr 1 '16 at 12:20
  • \$\begingroup\$ Each digit is an item in an array. And a function is defined so that the last item is popped off and 1 is added to that item. If the item is 10 then it recursively calls the function popping off the next item and so on. If it is not 10 then it just pushes the item back onto the array. \$\endgroup\$ – Adam Dally Apr 2 '16 at 0:40
  • \$\begingroup\$ Therefore, the stack size is equal to the number of digits. And 19299 digits leaves the largest number capable of running in this script to be 9.99999.... x 10^1929.9, much much larger than the number of atoms in the observable universe. The fastest computer in the world can do 33.86 x 10^15th operations per second, which would take 3.38 x 10^16 seconds if each operation were an entire iteration, or about a billion years, before the stack reached its max call size. :) \$\endgroup\$ – Adam Dally Apr 2 '16 at 1:03
2
\$\begingroup\$

awk , 65 bytes

BEGIN{for(;;){for(;++$++i>9;)$i=0;for(i=NF+1;i;)printf--i?$i:RS}}

Counts up "forever" using the fields as an array. I made sure this works with the standard Ubuntu awk (mawk).

\$\endgroup\$
2
\$\begingroup\$

GNU sed, 36

(score includes +1 for requiring the -r flag)

:=
p
s/$/1/
:
s/(^|_)1{10}/1_/
t
b=

This counts in unary-coded decimal, and must be primed with the starting number in UCD (e.g. 1) on stdin:

$ ./63834.sed <<<1 | head -n 30
1
11
111
1111
11111
111111
1111111
11111111
111111111
1_
1_1
1_11
1_111
1_1111
1_11111
1_111111
1_1111111
1_11111111
1_111111111
11_
11_1
11_11
11_111
11_1111
11_11111
11_111111
11_1111111
11_11111111
11_111111111
111_

Here's a version that takes input and output in decimal (now using x as the digit and 0 as separator):

#!/bin/sed -rf

s/[1-9]/0&/g
s/[5-9]/4&/g
y/8/4/
s/9/4&/g
s/4/22/g
s/[37]/2x/g
s/[26]/xx/g
s/[1-9]/x/g


:=
h
s/0x/-x/g
s/xx/2/g
y/x/1/
s/22/4/g
s/44/8/g
s/81/9/g
s/42/6/g
s/21/3/g
s/61/7/g
s/41/5/g
s/-//g
p

g
s/$/x/
:
s/(^|0)x{10}/x0/
t
b=

This is the same code, but with UCD/decimal conversion going on. This makes it easier to make it start at 2^128:

$ bc <<<'2 ^ 128' | ./63834.sed | head -n 10
340282366920938463463374607431768211456
340282366920938463463374607431768211457
340282366920938463463374607431768211458
340282366920938463463374607431768211459
340282366920938463463374607431768211460
340282366920938463463374607431768211461
340282366920938463463374607431768211462
340282366920938463463374607431768211463
340282366920938463463374607431768211464
340282366920938463463374607431768211465
\$\endgroup\$
2
\$\begingroup\$

Prolog (SWI), 35 bytes

p:-between(1,inf,N),writeln(N),1=2.

Edit: Saved 6 bytes thanks to @Fatalize

\$\endgroup\$
  • \$\begingroup\$ A 35 bytes solution is possible, using the SWI-Prolog predicate between/3 : p:-between(1,inf,N),writeln(N),1=2.. It will count up to infinity (inf) because of the 1=2 which will induce backtracking after each integer printed. \$\endgroup\$ – Fatalize Feb 2 '16 at 15:17
  • \$\begingroup\$ @Fatalize: oh right, you can use inf like that. \$\endgroup\$ – Emigna Feb 2 '16 at 19:58
2
\$\begingroup\$

Pylons, 8

1w1+p,1}

How it works:

1       # Pushes 1 on the stack.
w       # Starts a while loop.
 1+     # Pushes one and adds the top two elements of the stack.
   p    # Prints the stack. 
    ,   # Command,Condition seperator.
     1  # Condition, in this case, loop while 1.
      } # End the while loop.
\$\endgroup\$
2
\$\begingroup\$

GNU coreutils, 16 bytes

seq `bc<<<2^225`

GNU seq happily handles values over 2^128. 2^225 is the largest value bc will print without wrapping (it assumes 80-character width), so that's what I've used here.

Here's the proof that we can handle values higher than 2^227 (dc wraps one char later than bc):

$ seq `dc -e2d227^p` `dc -e2d227^10+p`
215679573337205118357336120696157045389097155380324579848828881993728
215679573337205118357336120696157045389097155380324579848828881993729
215679573337205118357336120696157045389097155380324579848828881993730
215679573337205118357336120696157045389097155380324579848828881993731
215679573337205118357336120696157045389097155380324579848828881993732
215679573337205118357336120696157045389097155380324579848828881993733
215679573337205118357336120696157045389097155380324579848828881993734
215679573337205118357336120696157045389097155380324579848828881993735
215679573337205118357336120696157045389097155380324579848828881993736
215679573337205118357336120696157045389097155380324579848828881993737
215679573337205118357336120696157045389097155380324579848828881993738
\$\endgroup\$
  • \$\begingroup\$ I discovered yesterday that GNU 'seq' will accept inf as the upper limit, but it then falls back to scientific notation (printf '%g' format), so it didn't help in the way I wanted... \$\endgroup\$ – Toby Speight Feb 19 '16 at 9:25
2
\$\begingroup\$

Bash, 31, 47 46 bytes

for((i=0;;i=`echo "$i+1"|bc`));do echo $i;done

I'm a bash novice but I've been wanting to use bash in code golf for a while. There must be a better way than this though, I'm sure it can be beaten!

I believe this fixes the issues.

> a=$((2**128))    # Too big
> echo $a
0

> a=$(echo "2^128"|bc)    # Works!
> echo $a
340282366920938463463374607431768211456

So all expressions are piped through bc to make sure it can handle them. It returns a string representation to the variable, which can then be printed. Open to golfing, maybe I can use bc better or maybe I can do code substitution better.

\$\endgroup\$
  • \$\begingroup\$ Does this satisfy the requirement of being able to reach 2^128 without running out of memory? \$\endgroup\$ – SuperJedi224 Feb 2 '16 at 15:05
  • \$\begingroup\$ Honestly, I don't know! Aside from letting it run, how would I find out? \$\endgroup\$ – Ogaday Feb 2 '16 at 15:06
  • \$\begingroup\$ What size are bash's integers? \$\endgroup\$ – SuperJedi224 Feb 2 '16 at 15:07
  • 1
    \$\begingroup\$ I'm getting the impression it's system defined, and probably won't be able to hit 2**128 \$\endgroup\$ – Ogaday Feb 2 '16 at 15:21
  • \$\begingroup\$ Bash only has 64-bit signed integers so you'll always be limited to 2^63-1 unless you outsource to bc, dc or similar. Or just use bc standalone... \$\endgroup\$ – Digital Trauma Feb 13 '18 at 19:23
2
\$\begingroup\$

F#, 50 49 36 bytes

let rec(!)d=printfn"%O"d;!(d+1I)
!1I

BigIntegers made this pretty easy, although I didn't know I could access them this easily in F#. =)

Update: It's even easier! You don't have to use bigint 1 when you can use 1I! =D

Without using BigInteger, I was able to get it down to 153 bytes. Note that this uses a base 256 representation, with a space between the digits and a newline between the numbers:

let rec i=function|255::[]->0::[1]|255::r->0::(i r)|n::r->(n+1)::r
let rec f d=printfn"%s"(List.rev d|>Seq.fold(fun s c->s+" "+(string c))"");f(i d)
f[0]

The function revolves around treating a list of byte-sized integers as a big number. The recursive function i increments that number (carrying changes up the digits by calling itself if needed), while the recursive function f prints the list as a number, increments the list, then calls itself.

Overall, a pretty fun problem. Thanks! =)

Saved a byte thanks to a trick I saw @Lynn do: name your functions with a character to call them more concisely. Thanks! =)

\$\endgroup\$
2
\$\begingroup\$

Hoon, 25 bytes

$:|=(a/@ ~&(a $(a +(a))))

Just repeatedly prints the sample of the gate, and recurses with a = a+1. Hoon's native number is a bignum backed by gmp, so it should be able to count up to 2^128 just fine. Simply paste that code into the Hoon repl (:dojo) in Urbit to run it.

It does abuse the feature of Hoon that gates are instantiated with a default sample, though. Pulling the $ arm for the gate runs it immediately, with the sample set to that default instead of having to call it with (f 0). It's actually smaller to do it this way instead of =+(a=0 |-(~&(a $(a +(a)))))

\$\endgroup\$
  • \$\begingroup\$ Is all of the whitespace necessary? \$\endgroup\$ – Addison Crump Feb 29 '16 at 1:16
  • \$\begingroup\$ Unfortunately, yes. It's the seperation of twigs: ~& takes two expressions, one to print and one to evaluate to. a(b c) is sugar for recursing to a with b set to c, so they have to be seperate expressions as well. The a/@ part is the type signature of the gate, and is even in a different syntax (tile syntax instead of twig). \$\endgroup\$ – RenderSettings Feb 29 '16 at 1:20
2
\$\begingroup\$

Aubergine, 61 bytes

=A1+i1
=bi-b1-b1:Ba+b1=oB+A1=aA-a1-ii               =oB-a1-ii

Try It Online! but be sure to hit Kill quickly so as to not crash your browser!

Prints in unary, one number per line. The Python interpreter, at least, will ensure it runs forever. (Make sure it is EXACTLY 61 bytes if you run it: adjust the number of spaces in the middle if it is not.)

How it works:

=A1                      SET MEM[0]=1 (this will be the counter).
   +i1                   JUMP 1 byte forward. (Skips the newline.)
   =bi-b1-b1             SET b=5 (points to the '1'=49 on the prev line)
   :Ba                   JUMP to 49 if a>0 (Will land on the other side of the spaces)
   +b1                   SET b=6 (now points to the newline)
   =oB                   OUTPUT what b points to (the newline)
   +A1                   INC MEM[0]
   =aA                   COPY MEM[0] INTO a (but we haven't printed the prev num yet!)
   -a1                   DEC a (Now a=the prev num)
   -ii                   JUMP to the beginning
                        (The sixth instruction jumps here when a>0:)
      =oB                OUTPUT contents of b ('1')
      -a1                DEC a
      -ii                JUMP to the beginning
\$\endgroup\$
2
\$\begingroup\$

Jelly, 3 bytes

Ṅ‘ß

Try it online! Be careful though, since this is a long output after all!

Ṅ            Print with newline
‘            Increment
ß            Call current link (function) again

Since there are no input arguments, the initial argument is taken to be 0.


Previous version:

Ṅ‘$ÐL

Try it online!

Ṅ            Print with newline
‘            Increment
$            Combine previous two
ÐL           Loop until
\$\endgroup\$
  • \$\begingroup\$ This should be ‘Ṅß instead, since the implicit argument is 0, so incrementation goes first. As it is right now, it's not valid at all. Your previous version also needs to be fixed. \$\endgroup\$ – Erik the Outgolfer Oct 6 '16 at 15:46
2
\$\begingroup\$

Perl, 20 19 bytes

perl -E 's//0/;say while++$_'

Magic string increment makes this work without bigint

\$\endgroup\$
2
\$\begingroup\$

Retina, 20 bytes

<empty line>
39$*0
+:T`9d`d`.9*$

Can count to 10**39-1.

Try it online!

Without leading zeroes (can count beyond 10**39): 23 bytes

+:(T`9d`d`.9*$
^0*$
1$&

Try it online!

13 bytes if pre-initialized with input as 39 "0"s:

+:T`9d`d`.9*$

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Retina, 73 bytes

No unary! Taken mostly from this SO answer. As noted by Martin, this code doesn't work in the newest version of Retina. Change (;`(\d+) to {;`(\d+) for it to work.

:`^$
1
(;`(\d+)
0$1~01234567890
:`^0(?!9*~)|(\d)(?=9*~\d*?\1(\d))|~\d*
$2

Try it online

It is much shorter if it was able use unary.

\$\endgroup\$
  • \$\begingroup\$ It doesn't work. \$\endgroup\$ – Leaky Nun Apr 23 '16 at 23:27
  • \$\begingroup\$ @KennyLau It used to at the time. I made some changes since then which broke backward-compatibility. You'd just need to turn the ( into a { to fix it. \$\endgroup\$ – Martin Ender Apr 25 '16 at 13:55
  • \$\begingroup\$ Perhaps you should include a version number in the answer header, then. \$\endgroup\$ – msh210 Apr 25 '16 at 18:34
  • 2
    \$\begingroup\$ @msh210 I'm not going to edit every single Retina answer I've ever posted every time Martin updates Retina. Look at the date I posted the answer, and use the version of Retina that corresponds to it. \$\endgroup\$ – mbomb007 Apr 25 '16 at 18:37
2
\$\begingroup\$

Scratch, 10 bytes

Script
(scoring used)
Resets, then adds n to the list and increases n by 1 in an indefinite loop.

\$\endgroup\$
  • \$\begingroup\$ Shorter: don't use "n" and add ((length of [list v]) + (1)) like this: puu.sh/pB9eQ.png \$\endgroup\$ – quat Jun 21 '16 at 22:12
2
\$\begingroup\$

UGL, 14 bytes

cul$oucuuu$*O:

Try it online!

How it works:

cul$oucuuu$*O:
cu              #i=1
  l          :  #while i:
   $o           #    print(i)
     u          #    i++
      cuuu$*O   #    print(chr(9))
\$\endgroup\$
2
\$\begingroup\$

Oracle SQL, 42 Bytes

select level from t connect by level=level
\$\endgroup\$
2
\$\begingroup\$

Brainfuck, 1055 bytes

+>+<[>[>[-]+<-]>[<+>>>>>>>>>[-]>[-]<[>+<-]<<<<<<<<-]>>>>>>>>>>>[<<<<<<<<<<<<+>>>>>>>>>>>>-]<<<<<<<<<<<<[>[-]+<-]>[<+>>>>>>>>>[-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>+>[-]<[>+<-][-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>>>[-]<<[<<<<<<+>>>>>>-]->>[<<<<<<<<-<+>>>>>>>>>-]<<<<<<<<<[>>>>>>>>>+<<<<<<<<<-]>[>>>>>>+<<<<<<[-]]<->>>>>>>[<<<<<<<->>>>>>>-]<<<<<<<[>>>>>>>+<<<<<<<-]>>>>>>>[>>>>+<<<<<<<<<<<<<->>>>>>>>>[-]]<<<<<<<<-]<[>[-]+<-]>[<+>>>>>>>>>>>>>>+<<<<<<<<<<<<<<->-]>>>>>>>>>>>>[<<<<<<<<<<<<<+>>>>>>>>>>>>>-]<<<<<<<<<<<<<[>[-]+<-]>[<+>>>>>>>>>[-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>[-]>[-]>[-]>[-]>>>[<<<<+[>+<<<<+>>>-]<<<[>>>+<<<-]+>>>>----------[<<<<->>>>[-]]<<<<[>>+>[-]<<<-]>>[>>+<<<<+>>-]<<[>>+<<-]+>>>>----------[<<<<->>>>[-]]<<<<[>+>[-]<<-]>>>>>>>-]<<<<<<[<++++++++[>++++++>++++++<<-]>.>.[-]<[-]]>[<<++++++++[>>++++++<<-]>>.[-]]<<++++++++[>>>++++++<<<-]>>>.[-]<<<++++[>++++++++<-]>.[-]<>>>>>>>>>>+<<<<<<<<<<<<->-]>>>>>>>>>>>>>[<<<<<<<<<<<<<<+>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<[>[-]+<-]>[<+<->>-]<<]

Too bad that Brainfuck has limited memory cell size. Actually, printing decimals and conditional statements are pain in this language. Ungolfed (or called so):

+>+<[

COUNTER=0

>[>[-]+<-]>[<+

>>>>>>>>>>[-]

LOOP START
    INCREMENTING <<<<<<<<<-]>>>>>>>>>>>[<<<<<<<<<<<<+>>>>>>>>>>>>-]<<<<<<<<<<<<[>[-]+<-]>[<+>>>>>>>>>[-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>+>[-]<[>+<-]
    CHECKING CELL [-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>>>[-]<<[<<<<<<+>>>>>>-]->>[<<<<<<<<-<+>>>>>>>>>-]<<<<<<<<<[>>>>>>>>>+<<<<<<<<<-]>[>>>>>>+<<<<<<[-]]<->>>>>>>[<<<<<<<->>>>>>>-]<<<<<<<[>>>>>>>+<<<<<<<-]>>>>>>>[>>>>+<<<<<<<<<<<<<->>>>>>>>>[-]]<<<<<<<<-]<[>[-]+<-]>[<+>>>>>>>>>>>>>>+<<<<<<<<<<<<<<->-]>>>>>>>>>>>>  [<<<<<<<<<<<<<+>>>>>>>>>>>>>-]


    PRINTING
                <<<<<<<<<<<<<[>[-]+<-]>[<+

                PRINT INTEGER

                >>>>>>>>>[-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>[-]>[-]>[-]>[-]>>>[<<<<+[>+<<<<+>>>-]<<<[>>>+<<<-]+>>>>----------[<<<<->>>>[-]]<<<<[>>+>[-]<<<-]>>[>>+<<<<+>>-]<<[>>+<<-]+>>>>----------[<<<<->>>>[-]]<<<<[>+>[-]<<-]>>>>>>>-]<<<<<<[<++++++++[>++++++>++++++<<-]>.>.[-]<[-]]>[<<++++++++[>>++++++<<-]>>.[-]]<<++++++++[>>>++++++<<<-]>>>.[-]

                PRINT SPACE

                <<<++++[>++++++++<-]>.[-]<


LOOP END

CODE THAT GETS EXECUTED AT THE END (LEAVING LOOP):

>>>>>>>>>>+<<<<<<<<<<<<->-]>>>>>>>>>>>>>[<<<<<<<<<<<<<<+>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<[>[-]+<-]>[<+<->>-]<<]

If we would remove last piece of code it would stick two '1' at the end.

\$\endgroup\$
  • 1
    \$\begingroup\$ Welcome to PPCG! There is already a brainfuck answer here, but multiple answers in the same language are perfectly fine here. Nice answer! \$\endgroup\$ – caird coinheringaahing Oct 24 '17 at 15:54
  • \$\begingroup\$ "Printing decimals and conditional statements are a pain in this language." Everything is a pain in brainfuck. That's sort of the point. \$\endgroup\$ – KSmarts Nov 17 '17 at 15:15
  • \$\begingroup\$ @KSmarts Not really, some things are ridicously easy \$\endgroup\$ – Krzysztof Szewczyk Nov 17 '17 at 19:17
2
\$\begingroup\$

Aceto, 5 bytes

IkpnO

Explanation:

Aceto follows a Hilbert Curve on a square program. If the program is not square, spaces are added to the top and right. (spaces do nothing) I

I - pops a value, increments it, and pushes it back on
k - makes the stack 'sticky', meaning that when popping a number, instead of removing the value it copies it
p - prints the top value
n - prints a newline
O - Returns the program back to the beginning

Also, can anyone explain to me why 'k' is needed? Shouldn't 'I' do the job just fine? When I omit 'k', it prints out lines and lines of '1's.

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Because p pops the value off the stack. \$\endgroup\$ – L3viathan Dec 12 '17 at 13:55
  • 1
    \$\begingroup\$ Glad to see people using it! \$\endgroup\$ – L3viathan Dec 12 '17 at 18:28
2
\$\begingroup\$

Alumin, 6 bytes

hqhanp

Alumin is a new language, made by @Conor O'Brien.

Explanation:

hqhanp
h      # Push 1
 q   p # Begin/end loop
  ha   # Push 1, add top two stack elements together (increments top)
    n  # Prints the top of stack as a number
\$\endgroup\$
2
\$\begingroup\$

Wumpus, 5 bytes

)=O
N

Try it online!

Explanation

The program runs )=ON in an infinite loop (see the "cat" answer for why that is).

)   Increment the top of the stack. Initially, this turns an implicit zero
    into an explicit one.
=   Duplicate.
O   Print as a decimal integer.
N   Print a linefeed.
\$\endgroup\$

protected by Community Mar 3 at 1:44

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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