Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.
This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

• You can get n any way.
• You can assume that n will always be a positive integer.
• You can get n in any base, but you should always output in decimal.
• Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).
• Standard loopholes are denied.
• We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.
• You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).
• You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

• Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.

• Related. – Martin Ender Apr 25 '16 at 12:20
• "You can get n any way." Does that mean we can assume n to be saved in a variable? – flawr May 21 '16 at 20:50
• @flawr You can get n any way. You can save it in a variable, but it must not be hardcoded. – Erik the Outgolfer May 22 '16 at 10:26
• It might be useful to link to the accepted I/O methods – Ephphatha Jun 2 '17 at 12:26
• @Ephphatha Yes it probably is, this challenge is from the old times where I was an utter newb. – Erik the Outgolfer Jun 2 '17 at 12:29

Jolf, 29 + 1 = 30 bytes

This in fact is valid! It uses the same technique as the JavaScript answer, keeping an array of digits. It should thus theoretically work, but may not work due to time limitations (browser crashing, etc.) Make sure to have "Pretty Output" enabled if it isn't already. (Apparently, making sure is an extra byte, like a flag, so there's that.) Try it here!

Ζ²1W<ni)aRζEΖZWζγwlζh.ζγonhn}


Ungolfed:

Z ~: 1
W < n i )
a R ζ E
Ζ ZW
ζ
w lζ
h .ζ w lζ
on h n
}


That's real clean-looking for a golfing language! :D

• What encoding is this? – Erik the Outgolfer Apr 26 '16 at 18:16
• You should add 1 byte because I must choose pretty output on. – Erik the Outgolfer Apr 26 '16 at 18:17
• @ΈρικΚωνσταντόπουλος You are right on the latter. Also, it's encoded in ISO-8859-7. You can upload a file on the website. (It's the encoding that bears your name in 1-byte characters ;)) – Conor O'Brien Apr 26 '16 at 18:22
• That's right. 2 more to go... – Erik the Outgolfer Apr 26 '16 at 18:41
• I don't think the encoding has to do something with here, as my name uses Unicode I think. – Erik the Outgolfer Apr 29 '16 at 17:40

C, 61 bytes

long i,n;main(){for(scanf("%ld",&n);i++<n;printf("%ld ",i));}


Essentially the same as my C++ answer, but C (or gcc) is more lenient of missing #includes, a missing return-type for main, and missing return-statements.

• I disagree. Not all compilers support missing #includes. So you should add 18 bytes. – Erik the Outgolfer Apr 27 '16 at 12:35
• gcc is considered sort of a golden standard as far as C compilers are concerned. Since default gcc has always supported missing #include <stdio.h>, and corner-cutting is in general encouraged in code-golf, I still think this is legit. @Dennis seems to agree in a comment to this question. – tucuxi Apr 27 '16 at 13:07
• You mean this comment? – Erik the Outgolfer Apr 27 '16 at 13:18
• Yes - and thanks to you, I now know how to link comments :-) – tucuxi Apr 27 '16 at 16:17
• Remember, you always learn, no matter your age. The date of the comment is it's link (click on it to be linked to that particular comment). – Erik the Outgolfer Apr 27 '16 at 17:29

Oracle SQL 11.2, 44 bytes

SELECT LEVEL FROM DUAL CONNECT BY LEVEL<=:1;

• Nice to see an answer in SQL derivatives! – Erik the Outgolfer Apr 27 '16 at 15:01

C++, 92 81 bytes

#include<cstdio>
long i,n;int main(){for(scanf("%ld",&n);i++<n;printf("%ld ",i));}


And another version, using iostream, with the same byte count

#include<iostream>
long i,n;int main(){for(std::cin>>n;i++<n;std::cout<<i<<' ');}


Not using long would result in 32-bit integers in most platforms<; also, C++'s iostream library with their std:: namespace are more verbose than C's I/O. (edit - I stand corrected, this is not true)

Update (-9 bytes): Learnt that return was optional in C++ thanks to @anatolyg

• Actually, I get exactly the same character count with cstdio as with iostream. Also, C++ doesn't require return 0. – anatolyg Apr 27 '16 at 14:46
• Thanks for the tip regarding return; also adding an iostream version, as you are again right - same byte count. – tucuxi Apr 27 '16 at 16:23

Common Lisp, 39 bytes

Disclaimer: I'm not responsible for any traumatic effect caused by the extreme density of parentheses. It's the language specification's fault. This one has surprisingly few parentheses!

(loop for a from 1 to(read)do(write a))


Brachylog, 7 bytes

:1:efrw


or alternatively

:1:efr.


Python 3, 43 42 bytes

x,i=int(input()),0
while i<x:i+=1;print(i)


Explained line-by-line:

x,i=int(input()),0
x  =int(input())   # Convert string input to integer, then assign x to it
,              ,  # Separate variables
i=             0 # Assign i to 0

while i<x:i+=1;print(i)
while    :              # Enter a WHILE loop
i<x               # Set limit
i+=1          # Count up
;         # Separate statements
print(i) # Print number


Old answer below. Hopefully this one will be able to count up to incl. 2**64-1.

Python 3, 41 bytes

for n in range(1,int(input())+1):print(n)


Ungolfed

for number in range(1, int(input()) + 1):
print(number)


Explained for those who can't understand

for n in range(1,int(input())+1):print(n)  # Code
for n in                        :          # Initiate a for loop with n as the number
range( ,              )           # The list of numbers we want to output in order
input()               # We get n from string input
int(       )              # We convert the input to integer
+1            # We add one to the range 'cause we want to include n
print( )   # We then output
n    # n is what we output

• This won't work for all 64-bit integers, so it is invalid by your own rules. – Dennis Apr 26 '16 at 18:07
• I think it works (language limit). If there is a way to make it work up to 2^64-1, please tell me. – Erik the Outgolfer Apr 26 '16 at 18:38
• You can use xrange(). Note: even xrange() may have issues, at least in 2.7.10. – user48538 Apr 26 '16 at 19:06
• I used it in my (sadly, shorter) Python 2 answer. – user48538 Apr 26 '16 at 19:07
• @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ as you only use your input once, you can just do while i<int(input)) . Also in your older version at 41 bytes, by removing the 1, in you range and the add 1 after the input, and placing either +1 after or -~ before the n in the print, it will be shorter and get the same answer. Also can I ask why your older answer is shorter, but you're not using it? – george Jun 15 '16 at 17:45

UGL, 14 11 bytes

ic^l_u$ocO^^-: il$d:_locO:


Uses U+0000 as delimiter.

Try it online!

Try it online! (14-byte version)

Explanation

This builds [9,8,7,6,5,4,3,2,1] for an input of 9, and then print them all out (with U+0000 as separator).

Explanation for 14 bytes

ic^l_u$ocO^^-: i # n = input() c # i = 0 ^l_ ^^-: # while i ~= n: u$o        #     print(i++)
cO      #     print(chr(0))


PHP, 2623 31 bytes

<?=join(' ',range(1,$argv[1])); // 31 if using N isnt allowed <?=join(' ',range(1,$n)); // 25 if using $n is allowed <?=join(' ',range(1,N)); // 24 bytes, join() is an alias of implode() <?=implode(' ',range(1,N)); // 27 bytes  "You can get n any way" -> In this case, N is a constant. Edit: Apperantly "any way" isn't "any way", it now takes commandline arguments • Hardcoding inputs is not allowed by default, and the author does not override that default (as you can see from this comment). – user45941 Apr 26 '16 at 9:33 • Updated accordingly – Martijn Apr 26 '16 at 9:55 • @Mego You are correct, I clearly state you must get n. I didn't do any override. – Erik the Outgolfer Apr 26 '16 at 10:48 • Which I interpretted as "I get N from a constant" ;) But, changed my answer to the proper interpretation – Martijn Apr 26 '16 at 12:30 • Isn't the statement-ending semicolon required? Omitting it on an online PHP codepad gives Fatal error: syntax error, unexpected$end, expecting ',' or ';' – nickb Apr 27 '16 at 4:05

Dip, 1 - .2 = .8

l


Body must be at least 30 characters; you entered 13.

• Can you provide a link to a Dip interpreter? I can´t find any reference to that language on the web. – Titus Jul 7 '17 at 15:20
• It was my language but i deleted it – Oliver Ni Jul 8 '17 at 16:24

C#, 10511710910710199 59 bytes

Golfed

void m(ulong u){while(u>=0)System.Console.WriteLine(u--);}


Ungolfed

void m( ulong u ) {
while (u >= 0)
System.Console.WriteLine(u--);
}


Releases

• v3.0 - -40 bytes - Changed the output to directly print to the console with a new line at the end. This update allows the usage of ulong. Once again, this is thanks to hstde.
• v2.4 -  -2 bytes - Replaced long with int due to the limitations of the capacity of List<T>, which is capped to the max of Int32.MaxValue in the implementation. The reason for changing to int can be found here. You can also explore this limitation in Reference Source.
• v2.3 -  -6 bytes - Using var instead of List<long>. Thanks to hstde.
• v2.2 -  -2 bytes - Fixed the decrements of the counter and removed brackets.
• v2.1 -  -8 bytes - Update to use the argument, making the code shorter and faster.
• v2.0 - +12 bytes - Update to List<> since arrays max size is Int32.MaxValue == 2 ^ 32 - 1
• v1.0 - 105 bytes - Initial release
• You're still gonna have a problem with anything bigger than int.MaxValue. But you can still shave off some bytes by replacing List<long>l with var l – hstde Nov 8 '16 at 10:46
• @hstde Unfortunately, as far as I know, the Array and List object in the .Net have a limitation of Int32.MaxValue ( 2 147 483 647 ) items. Although I haven't explore this fully, for what I've read you would most likely ran out of memory than hit the limitation of the objects. Please, correct me if I'm wrong. – auhmaan Nov 9 '16 at 14:41
• I played around a little and you indeed get an out of memory exception even when using something other then List<>. So the correct implementation would be an iterative from 0 to c. – hstde Nov 9 '16 at 14:57
• Even if I was able to implement a way to count up to the Int64.MaxValue - which is required by the challenge - I would hit the size limit of the String, which is Int32.MaxValue. – auhmaan Nov 9 '16 at 15:14
• You are right. That's why I need to learn to read... – auhmaan Nov 10 '16 at 17:47

Labyrinth, 412923 14 bytes

?}):
\ !
@"({


Try it online!

Takes the input number and moves it to the auxiliary stack and increments an implicit zero on the main stack. Repeatedly duplicates the top of the stack, outputs the number, moves a copy of the input number from the aux stack and decrements it. If that number is zero, the program exits. Otherwise it outputs a newline and continues the loop.

LibreLogo, 35 bytes

Code:

print set range 1 (int (input ")+1)


Input:

Output:

Taxi, 1,264 bytes

Line breaks are not required so here's the golfed version:

Go to Post Office: w 1 l, 1 r, 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery: s 1 l, 1 r.Pickup a passenger going to Sunny Skies Park.Go to Sunny Skies Park: n 1 l, 1 l, 1 r.[a]1 is waiting at Starchild Numerology.Go to Starchild Numerology: s 3 l.Pickup a passenger going to Addition Alley.Go to Go More: e 1 l.Go to Addition Alley: w 1 r, 3 r, 1 r.Pickup a passenger going to Cyclone.Go to Cyclone: n 1 l, 1 l.Pickup a passenger going to Cyclone.Pickup a passenger going to The Babelfishery.Go to The Babelfishery: s 1 l, 2 r, 1 r.Pickup a passenger going to Post Office." " is waiting at Writer's Depot.Go to Writer's Depot: n 1 l, 1 l, 2 l.Pickup a passenger going to Post Office.Go to Post Office: n 1 r, 2 r, 1 l.Go to Cyclone: s 1 r, 1 l, 2 r.Pickup a passenger going to Sunny Skies Park.Pickup a passenger going to Equal's Corner.Go to Sunny Skies Park: n 1 r.Pickup a passenger going to Cyclone.Go to Cyclone: n 1 l.Pickup a passenger going to Sunny Skies Park.Pickup a passenger going to Equal's Corner.Go to Sunny Skies Park: n 1 r.Pickup a passenger going to Addition Alley.Go to Equal's Corner: s.Switch to plan "b" if no one is waiting.Go to Taxi Garage: n 3 r, 1 r, 2 l, 2 r.[b]Go to Sunny Skies Park: n.Switch to plan "a".


And the formatted version for humans:

Go to Post Office: w 1 l, 1 r, 1 l.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: s 1 l, 1 r.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park: n 1 l, 1 l, 1 r.
[a]
1 is waiting at Starchild Numerology.
Go to Starchild Numerology: s 3 l.
Pickup a passenger going to Addition Alley.
Go to Go More: e 1 l.
Go to Addition Alley: w 1 r, 3 r, 1 r.
Pickup a passenger going to Cyclone.
Go to Cyclone: n 1 l, 1 l.
Pickup a passenger going to Cyclone.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: s 1 l, 2 r, 1 r.
Pickup a passenger going to Post Office.
" " is waiting at Writer's Depot.
Go to Writer's Depot: n 1 l, 1 l, 2 l.
Pickup a passenger going to Post Office.
Go to Post Office: n 1 r, 2 r, 1 l.
Go to Cyclone: s 1 r, 1 l, 2 r.
Pickup a passenger going to Sunny Skies Park.
Pickup a passenger going to Equal's Corner.
Go to Sunny Skies Park: n 1 r.
Pickup a passenger going to Cyclone.
Go to Cyclone: n 1 l.
Pickup a passenger going to Sunny Skies Park.
Pickup a passenger going to Equal's Corner.
Go to Sunny Skies Park: n 1 r.
Pickup a passenger going to Addition Alley.
Go to Equal's Corner: s.
Switch to plan "b" if no one is waiting.
Go to Taxi Garage: n 3 r, 1 r, 2 l, 2 r.
[b]
Go to Sunny Skies Park: n.
Switch to plan "a".


I can't find any documentation on integer limits, but my testing seems to show that Taxi can handle up to 64 bit signed integers but not un-signed. That means it can only count up to (2^63)-1.

QBIC - non-competing, 6 bytes

:[a|?b


Start a FOR-loop ranging from 1 (default start of FOR-loops) to a, where a is read by : from the command line parameters. At every iteration, b (our FOR-loop counter) is printed (?).

Stax, 1 byte

m


Run and debug online!

Added for completeness. That's it. Stax does it in 1 byte.

Pepe, 30 25 bytes

That's an amazing score for Pepe!

And now, I've saved 5 bytes because of the "flags" update. Now, instead of duplicating the item, I can set a flag to not remove it.

Also, Pepe seems to beat few practical languages now.

REeEREErEEEEErreEEreeERee


Try it online

This challenge made me rethink the control flows in Pepe. It helped me realize that I've created them completely wrong, so I remade them. ¯\_(ツ)_/¯ Thanks!

Warning: If you don't give any input or it will be smaller than 0, your browser will die.

Don't know if the bonus applies, if int's in JS support these numbers, then yes, otherwise no. My PC is not strong enough to print this large number in HTML.

Ungolfed:

REeE
REE
rEEEEE
r reEE
reeE
Ree


Explanation:

• REeE - Input number to stack R
• REE - Define label input
• rEEEEE - Increment item in stack r
• rEEEeE - Duplicate item in stack r
• r reEE - Pop Get value from stack r and print popped item as number - Flag r prevents removal of the item
• reeE - Output newline
• Ree - Goto label input if selected items in both stacks are equal

Basically, loop until the certain value is reached.

Brain-Flak, 14 bytes

{(({})[()])}{}


Try it online!

simply pushes the top stack value -1 until it reaches 0. Then it pops the zero and implicitly prints the stack

MAWP 1.0, 30 bytes

%@_1A[1A~25WWM~]~[!1A]%[:48W;]


Output takes a little while for larger numbers.

Try it!

C++, 91 bytes

Golfed:

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


Ungolfed:

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

• No C++ expert, but I think that int must return something. – Erik the Outgolfer Apr 25 '16 at 16:49
• Actually, no. The 'return 0' is implied by almost all modern compilers. – Michelfrancis Bustillos Apr 25 '16 at 17:04
• does std::cin>>c work i though it would cause type cast error char* to int... – Martin Barker Apr 26 '16 at 1:11
• @MartinBarker That error only occurs if the user inputs something other than an int. – Michelfrancis Bustillos Apr 26 '16 at 3:13
• You can declare x together with c to spare the second use of int, no need for the braces around a single instruction after for, you can increment x when outputting it so not need to mention it again inside for. At least g++ 5.2.1 accepts this (of course, after the include): int main(){int c,x;std::cin>>c;for(x=1;x<=c;)std::cout<<x++<<"\n";}. – manatwork Apr 26 '16 at 7:29

TI-Basic, 11 bytes

For(I,1,Ans:Disp I:End


I would do seq(I,I,1,Ans for 8 bytes but lists can't support 2^64 elements

• Could you support 2^64-1 with seq(I,I,1,Ans? – Erik the Outgolfer Apr 26 '16 at 8:17
• @ΈρικΚωνσταντόπουλος Yes, as a single element, but the entire sequence would exceed the 999 element limit for a list, and exceed the calculator's memory. – Timtech Apr 26 '16 at 18:41
• Then keep your 11-keystroke solution. – Erik the Outgolfer Apr 26 '16 at 18:42

Bash, 34 Bytes

for ((i=1;i<=$1;i++)); { echo$i;}


Split answer from GNU coreutils, this is pure bash.

• for((;i++<$1;));{ echo$i;} - 27 bytes. But bash uses 64 bit signed integers, so this will only go as far as 2^31 - 1 – Digital Trauma Apr 25 '16 at 17:54
• That's the limit for 32 bit integers, not 64. – CalculatorFeline Apr 26 '16 at 5:31
• @DigitalTrauma 64-bit integers meet the spec (2^64-1), 32-bit ints don't. It's fine, though. – Erik the Outgolfer Apr 26 '16 at 8:19
• The sign uses one of the 64 bits (not half of them!), so bash's maximum is 2^63-1 (empirically verified). – joeytwiddle Apr 26 '16 at 14:39
• @CatsAreFluffy ha - of course I meant 2^63-1. 2^31 is an old force of habit I suppose. Still doesn't meet the spec IMO. – Digital Trauma Apr 26 '16 at 14:57

PGP, 28 Bytes

PHP Golf Processor (https://github.com/barkermn01/PGP-php-CodeGolf/) to run it php pgp.php file.pgp or php pgp.php '{code here}'

f(;$i!=$argv[1];)e ++$i." ";  • Can't you remove the space? e ++ – Erik the Outgolfer Apr 29 '16 at 17:49 • Not yet, your welcome to code it it in and send me a pull request :) – Martin Barker Apr 30 '16 at 21:16 • how about f(;$i++!=$argv[1];)e"$i ";? – Titus Jul 26 '16 at 1:38

Molecule, 10 bytes

0{1+~}InL.


Explanation:

0{1+~}InL.
0          Push 0
{1+~}     Create a code block
In   Ask the amount of times to repeat
L. Loop the code block n times and clean the stack.


Ruby, 18 12 bytes

->n{p *1..n}


-3 bytes from Not that Charles, and -3 more from daniero

• Can't you remove that space? – Erik the Outgolfer Apr 27 '16 at 13:14
• @ΈρικΚωνσταντόπουλος No. if i do it will try to multiply. – MegaTom Apr 27 '16 at 15:10
• Oh 13 more to go... – Erik the Outgolfer Apr 27 '16 at 15:41
• You can use p instead of puts – daniero Apr 29 '16 at 11:56

Scratch, 12 10 bytes

(scoring used)
Asks for the end number, resets, and counts up.

• Finally an answer! – Erik the Outgolfer May 20 '16 at 14:51
• Scratch projects are meant to run multiple times. – weatherman115 May 20 '16 at 15:24
• See my remix – Erik the Outgolfer May 20 '16 at 15:34
• Well, you can golf it more: 1) Replace ask[\]]and wait with ask[]and wait for -1 point 2) To conform with the rules, you must say[] or say[]for()secs each and every number ("think" is considered STDERR for this challenge). So instead of add(c)to[list v use say(c 3) Since you do not need the list anymore you can remove the delete(all v)of[list v block for another -1 point. so you save a total of 2 points, resulting 10 points (both versions) – Erik the Outgolfer May 20 '16 at 15:37
• scratchblocks – Erik the Outgolfer May 21 '16 at 13:14

Tellurium, 6 bytes

[I|+^]


This code runs a loop for an amount of times specified by the user (I). + adds one to the cell's value and ^ outputs the value.

Desmos, 60+table bytes

l=\left[1,2,...,\operatorname{floor}\left(a\right)\right]
a=0


I have a set to 0 because the table would contain extra spaces if I didn't. That said, there isn't currently scoring for the table, which I've asked about on meta.

PyCal, 6 bytes

*i[+^]


This runs the code +^ for n times.

+ adds one to the variable and ^ outputs the variable's value. Simple enough.

EDIT: Interestingly enough, this solution is the exact same length as my Tellurium (another esoteric language I made) solution.

Python 2, 36 bytes

i=0
x=input()
while i<x:i+=1;print i


Explanation

Line 1

i=0 Generate the accumulator

Line 2

x=input() Store the number

Line 3

while Loop i<x while the accumulator is smaller than the number.

Line 3.1

i+=1 Increment the accumulator.

Line 3.2

print i Print the accumulator.