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

# Leaderboard

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
• @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
• I can't believe every single of the (currently) 71 answers assumes the base should be decimal… – Skippy le Grand Gourou Jul 22 '16 at 15:05

# Go, 73 bytes

package main
import "fmt"
func main(){for i:=1;i<11;i++{fmt.Println(i)}}


Try it online!

• Hello, and welcome to PPCG! This is a great first post. – NoOneIsHere Jul 21 '16 at 21:03
• Normally, we use a header like I edited in with the number of bytes in your submission. – NoOneIsHere Jul 21 '16 at 21:05

# Befunge, 14 * 3 - 1 = 41 bytes

0v          <
>:1+::.55+-|
@


Quick and dirty befunge '93 solution. I'm sure it could be improved, maybe I'll look into it tomorrow. 41 bytes is the 14 * 3 grid in total, excluding a final newline, there are actually 16 characters in the source.

# Befunge-93, 12 bytes

1::.9#@_1+#


Explanation:

1             Start stack with the number 1
:.          Print the number on top of the stack
:  9        Set (number on top of the stack) > 9
#       Skip the next character, which would otherwise stop the program
_     Is the number in the top of the stack true (i.e. not 0)?
@      If yes, stop the program
1+   If no, add 1 to the top of the stack
#  Skip the next character. Since we're at the edge of the program,
it would wrap to the beginning, so the character being skipped is
the "1" at the left edge. That is, "don't put 1 on the stack again"


# F# 17 bytes

Equal to Haskell !! yuppee.

printf"%A"[1..10]


Output:

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


For each number on a separate line, 28 bytes:

Seq.iter(printfn"%d")[1..10]


If you remove the standard output permission, simply [1..10] prints out the numbers in F# interactive.

[1..10];;
> val it : int list = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]


# Maple, 10 bytes

seq(1..10)


Output:

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


# Verbosy 31 Bytes

~0 /0 ~10 /1 :a: ^0 o \0 -1 >-a


Verbosy is a language that I wrote btw. The explanation can be found in README.md.

# JavaScript with UnderscoreJS, 20 Bytes

alert(_.range(1,11))

• A similar solution was posted here. Posting a comment suggesting a byte improvement may be a good option next time :) – Swivel Jul 22 '16 at 20:16
• That´s not one byte, that´s 50%. – Titus Jul 28 '17 at 5:36

# JShell (Java 9), 37 36 bytes

for(int i=1;i<11;i++)printf("%d ",i)


Java 9 has a REPL called JShell. You'll need an early access build of Java 9 to run it. Once it's installed, just run jshell, paste, and voilà !

Realized after looking at other solutions that newlines aren't a requirement. Saved 1 byte.

# JavaScript, 30 bytes

for(i=0;i++<10;)console.log(i)


But I still love it that good old for beats all the pretty ES versions:

[...Array(10)].map((_,i)=>console.log(i+1)) 43 Bytes
alert([...Array(10)].map((_,i)=>i+1)) 37 Bytes
alert(Array(10).fill().map((_,i)=>i+1)) 39 Bytes
i=[...Array(11)].keys();i.next();alert([...i]) 46 Bytes
alert([...[...Array(11)].keys()].slice(1)) 42 Bytes
alert([...Array(11).keys()].slice(1)) 37 Bytes

• why do you need the |0 in the second functional solution? – Paolo Bonzini Jul 22 '16 at 16:30
• @Paolo Bonzini: not needed ... copy&paste leftovers – Titus Jul 22 '16 at 16:37
• Someone already did this, although they used alert instead of console.log. – Neil Jul 22 '16 at 19:48
• @Neil: Thought I had browsed all answers. Can you link it? – Titus Jul 22 '16 at 20:09
• @Titus It was one of the first ;) – Swivel Jul 22 '16 at 20:13

# Kona, 5 bytes

Code:

1+!10


Output:

1 2 3 4 5 6 7 8 9 10


## ROOP, 15 bytes

12345689
h(10)


Solution with hardcoded numbers, I'm still trying to find a shorter program.

In this language each digit becomes an individual object. Number 10 is written in parenthesis to make it a single object. The operator h prints all objects that are currently in the program, separated by a space, then halt.

# GolfScript, 5 bytes

11,(;


Try it online!

• The official interpreter produces no whitespace (or comma) between the values. – primo Jul 24 '16 at 11:58

# CoffeeScript, 19 characters

console.log [1..10]


Sample run:

bash-4.3$coffee -e 'console.log [1..10]' [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]  On-line test # MoonScript, 17 characters (Rewrite of Katenkyo's Lua answer. Appreciations should be expressed by upvoting the original answer.) for i=1,10print i  Sample run: bash-4.3$ moon <(echo 'for i=1,10print i')
1
2
3
4
5
6
7
8
9
10


JavaScript, 31 bytes

for(i=1;i<11;i++)console.log(i)


Just a for loop that prints the number on every execution. The range of the for loop is 1 to 10.

# Clojure, 20 bytes

(print (range 1 11))


Output:

(1 2 3 4 5 6 7 8 9 10)


## K, 5 Bytes

    1+!10
1 2 3 4 5 6 7 8 9 10


Explanation;

!2    --> 0 1
!5    --> 0 1 2 3 4
!10   --> 0 1 2 3 4 5 6 7 8 9
1+!10 --> 1 2 3 4 5 6 7 8 9 10


## C#, 54 bytes

n=>{for(int i=1;i<11;)System.Console.Write(i+++" ");};

• Only one byte shorter than n=>{System.Console.Write("1,2,3,4,5,6,7,8,9,10");};. Silly C#! Edit: Actually, if I take out the spaces VS added, this comes in at 51... – BMac Oct 19 '16 at 0:57
• @BMac Yeah but solutions like that are no fun! And with the above I could pass I through as an argument and force it to 1 saving 4 bytes and probably some other changes :) On second thoughts that's disallowed so no I can't do that – TheLethalCoder Oct 19 '16 at 8:20

# RETURN, 7 bytes

1{11
}.


Try it here.

## Batch, 35 bytes

@for /l %%i in (1,1,10)do @echo %%i


Hardcoding would have saved 10 bytes...

• you can cut the CR/LF to save two bytes. – peter ferrie Mar 16 '18 at 4:15
• @peterferrie But there is no CR/LF... – Neil Mar 16 '18 at 8:48

# Fourier, 12 bytes

Prints a leading newline

10(10aX^o~X)


Try it online!

# TI-BASIC, 9 bytes

seq(X,X,1,10


TI-BASIC is tokenized, so seq( is represented as 1 byte, as are all the other characters. The seq function is actually more powerful: the first X is an expression, and the second X is the variable that is used in the expression using the values 1 to 10, instead of using the predefined variable for X. For example, the squares of the numbers from 1 to 10 would be seq(X²,X,1,10.

## Emmet (HTML) - 6 bytes

You'll have to excuse me, I'm new to code golf but I think I understand the concept.

{\$}*10


Output:

12345678910


Alternatively, if it's required for the numbers to be seperate, adding a p infront of the braces will put it into <p> tags, like so:

<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
<p>10</p>


It also requires a tab to make it "go", I've left that out of the byte count.

Please let me know if I've stuffed up somewhere. Thanks!

# Silicon, 3 bytes

(Silicon uses CP037, so 3 bytes, not 4.)

0Â\


Explanation:

0Â\
\     Push a list with the numbers in the range...
0       Zero
Â      Ten


## Seriously/Actually, 3 bytes

9uR


Try it online: Seriously, Actually

Explanation:

9uR
9u   push 9, increment (10)
R  range(1, 11) ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])


## GNU sed, 22 21 bytes

c1 2 3 4 5 6 7 8 9 10


With coreutils, the code is only 7 bytes long!

eseq 10


Adding to the diversity of languages used so far, I present a sed solution. The consensus is that sed is exempt from the "no input" rule, since the script doesn't start without.

Run:

echo | sed -f script.sed


# APL, 3 bytes

⍳10


Explanation:

⍳   range
10   10

• Of course, your ⎕IO must be 1. – Zacharý Nov 15 '16 at 0:53
• @ZacharyT Which is its default value – Cows quack Mar 25 '17 at 19:48
• Depending on the APL you use. – Zacharý Mar 26 '17 at 23:18

# k, 5 bytes

1+!10


Explanation:

1+ //Projection of +, add 1 to the argument
!10 // "til" 10 - i.e. generate a list of numbers from 0 to n-1


Output:

1 2 3 4 5 6 7 8 9 10

• You can also do 1_!11, which seems faster (at least in kdb+).. count 0..10 then drop the first element, rather than adding 1 to each item of a 10 item list. – streetster Jun 15 '17 at 22:34

# Java 7, 50 bytes

void m{for(int i=1;i<11;System.out.println(i++));}

• Welcome to Programming Puzzles & Code Golf! Just so you know, the downvote was cast automatically by the Community user when your answer was edited. I consider this a bug. I'd upvote, but I don't know Java and have no idea how to test your code. Could you maybe include a link to an online interpreter? – Dennis Oct 18 '16 at 16:38

# TrumpScript, 45 bytes

Say "1 2 3 4 5 6 7 8 9 10"!
America is great.


Don't even try using a loop... it's much much longer.

Edit: to clarify, TrumpScript uses only numbers greater than 1,000,000, so counting from 1 to 10 would require a lot of variables.