# Print numbers from 1 to 10

This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

This is , so shortest answer in bytes wins!

var QUESTION_ID=86075,OVERRIDE_USER=42570;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<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="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><div id="language-list"> <h2>Winners 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><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>

• Related (duplicate?) – Luis Mendo Jul 21 '16 at 9:07
• If the only change is hard-coding a single parameter then that falls under the banner of "trivial change", and by the standards of this site still counts as a dupe. – Peter Taylor Jul 21 '16 at 9:54
• @PeterTaylor The other challenge has a huge problem with the integer limits though. The way it's specified every TC language that doesn't have 64-bit integers needs to implement them. (And that affects quite a lot of languages.) – Martin Ender Jul 21 '16 at 10:01
• @MartinEnder It's too bad the other question has the silly limitation, but I still think it's a dupe when one can port over 2/3 or more of the answers with only minor modification. – xnor Jul 21 '16 at 10:50
• @xnor Quite frankly, I'd rather close the other challenge as a duplicate of this one. The requirement pretty much ruins it. – Dennis Jul 21 '16 at 14:09

# Sesos (binary), 5 bytes

Hexdump:

0000000: 2c4bbc 3301                                       ,K.3.


Try it online!

### How it works

The binary file above has been generated by assembling the following SASM code.

Sesos is a language "based on brainfuck", but is "concise, can be typed easily, has somewhat flexible I/O, and is safe for work".

set numout    ;sets the output to printing a number per line,
add 10        ;now the tape is [10,0,...]
jmp           ;start of loop
fwd 1          ;forward the data head
put            ;output (as number)
rwd 1          ;rewind the data head by 1 cellby 1 cell
sub 1          ;subtract 1 from the cell under data head
;the tape goes from [0,10] to [1,9], to [2,8]
;to ... [8,2] to [9,1] to [10,0] and then halts.
;(implicit jnz) end of loop, goto "jmp" if not zero


In brainfuck: ++++++++++[>+.<-] (assuming decimal output).

## Plain TeX (58 bytes)

\newcount\c\loop\advance\c1 \the\c\ \ifnum\c<10\repeat\bye


# PostScript, 12 bytes

1 1 10{=}for


Output:

1
2
3
4
5
6
7
8
9
10


(Most PostScript interpreters don't actually have a proper stdout, or even a command line, but GhostScript has both and can be used to run this program.)

# 𝔼𝕊𝕄𝕚𝕟, 7 bytes

⩤ 1,Ⅹ


Prints out

1,2,3,4,5,6,7,8,9,10


Implicit print, Ⅹ is 10 and ⩤ is range(a, b) so the overall pseudocode is stdout.write(range(1, 10))

Note that, while it is only 5 characters, it still takes up 7 bytes, this is due to the Ⅹ and the ⩤ not being ASCII characters. (Ⅹ is the Roman numeral version)

• O my god, another ESMin golfer! Yay! Also, ⩤⁽1Ḋ is 4 chars/7 bytes (Ḋ is the variable for 10, and ⁽ groups numbers/variables into arguments). – Mama Fun Roll Aug 2 '16 at 15:05
• @MamaFunRoll Yeah, ESMin is awesome! Thanks for the tip. – emiflake Aug 2 '16 at 15:07

# ><> (Fish) 10 bytes

1l:naoa=?;


This is my first submission and I know their is already a Fish answer but I don't have the reputation to comment.

The main difference is using the l to place the length of the stack onto the stack allowing us to bypass 'adding one' saving a byte.

Using l also means we don't need to preserve the stack value (just the length) so we do not need to duplicate the top of the stack to preserve our values, saving another 2 bytes (one for the duplication of the stack value and another as we do not need to skip any instructions for preserving the stack).

# Julia, 12 bytes

show([1:10])


In Julia, x:y is a range, inclusive. To cast to a list you need to put brackets around it. Otherwise it will just print the literal characters 1:10.

1 byte saved due to @Dennis. Turns out show works the same as print in this case.

• show([1:10]) is 12 bytes, not 13. That needs to be fixed in the header. – user48538 Jul 21 '16 at 13:32

# Atari Basic, 29 Bytes

1 for i=1 to 10
2 ? i
3 next i

• 1 for i=1 to 10:? i:next is probably more concise? I'm certain that Atari BASIC allows multi-statemented lines – Shaun Bebbers Mar 9 '18 at 10:30
• Also if Atari BASIC is similar to Commodore (Microsoft) BASIC, you won't need to say next i - simply next – Shaun Bebbers Mar 9 '18 at 10:31

## PHP, 25 23 bytes

Saved 2 bytes thanks to manatwork.

 <?=join(_,range(1,10));


Creates an array of [1 .. 10] and echoes the values separated by _s.

• You could take advantage of the freedom to choose the separator. Using “_” as Martin Ender's Retina solution does would reduce the length by 2. (At the obvious price of an undefined constant notice, which is fine as PHP's suggested production configuration not displays notices anyway.) – manatwork Jul 21 '16 at 14:08
• @manatwork: That is very strange, I had no idea that was even possible. Thanks for the suggestion! – Business Cat Jul 21 '16 at 14:16
• Same length: for(;$i++<10;)echo$i,_; – Ismael Miguel Jul 22 '16 at 2:36
• @IsmaelMiguel: That's longer because it requires the full <?php and not just <?= – Business Cat Jul 22 '16 at 12:38
• True. and the join(_ is prettier anyway; just keep it like that. But let me add two variations of Ismael´s idea: while($i<10)echo++$i,_; and while(++$i%11)echo$i,_; (same length, but with -r) – Titus Jul 22 '16 at 14:12

# MATLAB/Octave, 4 bytes

1:10

Simply prints the numbers 1 through 10 as a vector, with spaces separating them (may have newline if your window is not wide enough)

• Does it matter that this also outputs ans = ? You may need to wrap it in a disp – Suever Jul 22 '16 at 1:59
• @Suever no, I don't think so. "Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), prefixes and postfixes (like [...]). However, you may not output any other numbers." There are no extra digits or numbers. – bers Jul 23 '16 at 18:24

# BrainFuck, 55 Bytes

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


Output:

1   2   3   4   5   6   7   8   9   10


(Indents as seperators)

Try it here:

https://fatiherikli.github.io/brainfuck-visualizer/#KysrKysrKysrPi0tPi1bLS0tLS08Kz5dKysrKysrKysrWy08Lis8Lj4+XTw8Wy0+LTxdPi4tLg==

# Excel 6 bytes

=ROW(

Select the cells A1:A10, type the above (once only) and ctrl-shift-enter as an array formula (which links the cells in an array, with one common formula).

Note the total lack of numerals entered in this process. :-)

• Not sure this is allowed. It requires a specific state (A1:A10 selected) and input (1,2,3,4,5,6,7,8,9,10) – Cyoce Sep 2 '16 at 0:45
• @Cyoce It doesn't require any numeric input. The range selection could potentially be specified with f5 A1:A10 enter which would be 8 more keystrokes. – Joffan Sep 2 '16 at 16:25

PPPPPz_G]


This is basically ++++++++++[>+.<-] in BrainFuck and outputs the numerical values as character codes.

Try It Online!

• Removing a byte: PPPPPz_G] – Addison Crump Aug 2 '16 at 20:13

# T-SQL, 53 46 Bytes

Saved 7 bytes thanks to @t-clausen.dk

DECLARE @ INT=1z:PRINT @ SET @+=1IF @<11GOTO z


Also 17 bytes (though it feels like cheating):

PRINT 12345678910

• Can be done easier, here are 2 examples - fiddle – t-clausen.dk Aug 29 '16 at 9:31

## Stata, 40 bytes

loc i=1
wh i'<11 {
di i'
loc i=i'+1
}


Output

1
2
3
4
5
6
7
8
9
10

• Hello, and welcome to PPCG! Do you need all the whitespace? – NoOneIsHere Sep 1 '16 at 17:36
• Thank you. Yes, the whitespace is required, alas. – f1rstguess Sep 1 '16 at 17:43
• You can use a global (gl) instead of local. Then you access the variable with $i. That should save some bytes. I'm happy to find another STATA user on PPCG! – bmarks Feb 17 '17 at 5:06 ## Morse code, 65 bytes .---- ..--- ...-- ....- ..... -.... --... ---.. ----. .----- ----  Copy and paste here to try it out (and listen to the code): http://morsecode.scphillips.com/translator.html ## Hexagony, 31 bytes <8!~\\\..)\M\~={{'$;$@.......9$


Try it Online!

Still feeling that there are too many no-ops. Had a 34 bytes first draft:

<{."@;.)!.8.{{..M.\\.\'.$(...0=..1  ### Expanded 31 bytes solution  < 8 ! ~ \ \ \ . . ) \ M \ ~ = { { '$ ; $@ . . . . . . . 9$ . .
. . . .


As in the first draft, uses a < to deflect the IP to NW direction.

This trick is found to be quite useful (for me) when the ending path is short enough after a loop.

Instead of using 10, I used 9 and negate it so the loop is still running 10 times (-9 -8 ... 0 all to the "Left" branch).

Although I managed to increase the number of no-ops in the main loop (NW), I can't modify the main loop due to positioning concerns... Maybe easier to golf off more bytes without using the negation trick.

And though I very much like re-using ops, this time I left a lot of no-ops and used a lot of \$ skip commands to keep the loop running.

Oh I really love this language!

# JavaScript, 14 bytes

_=>12345678910


In the question, it doesn't say anywhere that you must use a delimiter. In fact, it says that I can use any output format that I want, so this answer is valid.

## Brainfuck, 53 bytes

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


# Whitespace,

71 bytes, thanks to LeakyNun,

# 63 bytes, thanks to Kevin

Spaces substituted with S, tabs with T, linefeeds with L:

SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL


Run it!

Output:

1
2
3
4
5
6
7
8
9
10

• @LeakyNun Ok, i'll update the code. I used Notepad++ for the bytecount. – ABcDexter Jul 24 '16 at 8:42
• You can save a lot of bytes by changing the two labels to just one byte. – Leaky Nun Jul 24 '16 at 9:35
• i.e. here: SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL LSSSL LLL – Leaky Nun Jul 24 '16 at 9:37
• that would be 71 bytes – Leaky Nun Jul 24 '16 at 9:40
• You can remove the exit and second label: SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL. It will exit with an error after it has outputted all 10 integers, but that's allowed according to the meta. Try it online (63 bytes). – Kevin Cruijssen Mar 13 '18 at 20:28

# Whitespace, 61 59 bytes

[S S S T    N
_Push_1][N
S S N
_Create_Label_0][S N
S _Duplicate][T N
S T _Print_integer][S S S T N
_Push_1][T  S S S _Add][S N
S _Duplicate][S S S T   S T S N
_Push_10][S N
S _Duplicate][T N
S S _Print_char][S N
T   _Swap][T    S S T   _Subtract][N
T   T   S N
_Jump_to_Label_1_if_negative][N
S N
N
_Jump_to_Label_0]


Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online.

Explanation:

Command    Explanation                 Stack          STDOUT    STDERR

SSSTN      Push 1                      [1]
NSSN       Create Label_LOOP           [1]
SNS        Duplicate (1)              [1,1]
TNST       Print as integer           [1]            1
SSSTN      Push 1                     [1,1]
SNS        Duplicate (2)              [2,2]
SSSTSTSN   Push 10                    [2,2,10]
SNS        Duplicate (10)             [2,2,10,10]
TNSS       Print as character         [2,2,10]       \n
SNT        Swap top two               [2,10,2]
TSST       Subtract (10-2)            [2,8]

SNS        Duplicate (2)              [2,2]
TNST       Print as integer           [2]             2
SSSTN      Push 1                     [2,1]
SNS        Duplicate (3)              [3,3]
SSSTSTSN   Push 10                    [3,3,10]
SNS        Duplicate (10)             [3,3,10,10]
TNSS       Print as character         [3,3,10]        \n
SNT        Swap top two               [3,10,3]
TSST       Subtract (10-3)            [3,7]

...

SNS        Duplicate (9)              [9,9]
TNST       Print as integer           [9]             9
SSSTN      Push 1                     [9,1]
SNS        Duplicate (10)             [10,10]
SSSTSTSN   Push 10                    [10,10,10]
SNS        Duplicate (10)             [10,10,10,10]
TNSS       Print as character         [10,10,10]      \n
SNT        Swap top two               [10,10,10]
TSST       Subtract (10-10)           [10,0]

SNS        Duplicate (10)             [10,10]
TNST       Print as integer           [10]            10
SSSTN      Push 1                     [10,1]
SNS        Duplicate (11)             [11,11]
SSSTSTSN   Push 10                    [11,11,10]
SNS        Duplicate (10)             [11,11,10,10]
TNSS       Print as character         [11,11,10]      \n
SNT        Swap top two               [11,10,11]
TSST       Subtract (10-11)           [11,-1]


## Lua, 25 Bytes

for i=1,10 do print(i)end


# Brachylog, 6 5 bytes

Saved one byte thanks to @mat

10yb.


Try it online!

### Explanation

10y        Get the list [0:1:2:3:4:5:6:7:8:9:10]
b.      Output is that list minus the first element

• 5 bytes: 10yb. – mat Jul 21 '16 at 11:57
• @mat Thanks, I didn't thought of that, even though it's even simpler! – Fatalize Jul 21 '16 at 12:00

## Perl 5.10, 14 13 bytes

Almost the same as Perl 6:

say for 1..10


I could've done something like say"@{[1..10]}" which is the exact same thing as in Perl 6, but it is too long. :p

Each number is outputted on a separate line.

Thanks to manatwork for saving 1 byte!

Try it here!

• No need for parenthesis around statement modifier's condition. – manatwork Jul 21 '16 at 14:10
• @manatwork Indeed, thanks! – Paul Picard Jul 21 '16 at 14:11
• OP says separators are ok but not required. I'd just use say 1..10 – Alex Howansky Jul 21 '16 at 17:47

## Brainfuck, 66 Bytes

Sadly, Someone found a 58 Bytes solution, but as we both have different way of solving this, I'll post mine anyway.

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


Output: 1/2/3/4/5/6/7/8/9/10

Here's what the tape looks like at each step, the * shows where the pointer lies.

+++[>+++>++<<-] tape (0*:9:6)cell-2: counter for printing;cell-3: used for ascii-value of 1
>>+[>+++++++<-] tape (0:9:0*:49) 49 is the ascii value of 1
>[>+>+<<-<+>]   tape (0:9:49:0*:49:49) duplicate it 3 times
<--<            tape (0:9*:47:0:49:49) one will be used as a delimiter "/"
[>>>.+<<.<-]    tape (0:0*:47:0:57:49) outputs the numbers 1..9 separated by "/"
>>>>.-.         tape (0:0:47:0:49:48) outputs 10


# Common Lisp, 29 bytes

(dotimes(n 10)(print(+ n 1)))

• Perhaps this would save 1 byte? (dotimes(n 10)(print(1+ n))) – gsl Jul 23 '16 at 8:11

## Convex, 3 bytes

A´


Try it online!

## Swift 3 (Jun 20, 2016), 20 bytes

print(Array(1...10))


Try it online!

Just doing print(1...10) (un)surprisingly prints 1...10 to STDOUT, so we need to unwrap the Range object into an Array. A Set would be shorter, but does not guarantee order (and in practice doesn't, either).

# Julia 0.2, 11 bytes

print(1:10)


Pretty self explanatory. 1:10 is a range, and print expands it.

# Cheddar, 7 bytes

->1|>10


Prett simple. |> is range operator. [0, 10] is:

->|>10

• What does -> do? Also pretty* – Cyoce Sep 2 '16 at 1:15
• @Cyoce -> is a function with no arguments. Like ()=> in JavaScript but in Cheddar if you have no args you can drop the parens – Downgoat Sep 2 '16 at 1:49

# Elixir, 18 bytes

for n<-1..10,do: n


Output:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


Note: This is using iex, the Elixir REPL.