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

Firebird, 113 bytes

The compacted select, used to calculate the score is below:

WITH RECURSIVE T AS (SELECT 1 AS I FROM RDB$DATABASE UNION ALL SELECT 1+I FROM T WHERE I < 10 ) SELECT * FROM T  The formated select: WITH RECURSIVE T AS ( SELECT 1 AS I FROM RDB$DATABASE
UNION ALL
SELECT 1+I
FROM T
WHERE I < 10
)
SELECT *
FROM T


Short explanation: I start with a select on a system table from firebird, witch always has only one record. Then, using recursion on that projection, I add the column "I" until it reaches 10.

• Welcome to PPCG! Seems like a decent first post, but I think that you could improve it by giving a short explanation for how it works. – Taylor Scott Jun 22 '17 at 19:56
• Thanks. Yes, I should have add a short explanation on my answer. Already updated it. – Filipe Santos Jun 22 '17 at 20:00
• Can you remove some of the spaces/newlines? – CalculatorFeline Jun 22 '17 at 20:02
• @CalculatorFeline Yes I Can! Will do that now, thanks! – Filipe Santos Jun 22 '17 at 20:04

# Python 2.7, 17 bytes

print range(1,11)


Why 11? The range() function is non-inclusive for the end argument.

repl.it

• Duplicate of TuukkaX's Python2 answer posted 11 months earlier. (With sufficient privileges you could see that there are already 3 completely or partially identical deleted answers too.) – manatwork Jun 23 '17 at 7:51
• @manatwork Oops. Sorry. – juniorRubyist Jun 23 '17 at 16:16

# Swift 3, 20 bytes

print(Array(1...10))

• Welcome on Programming Puzzle & Code Golf. About the downvote on your answer: it was automatically applied by the system when @Toto edited your answer from the "First Post" review queue; but no one actually downvoted it. Happy golfing! – Dada Jun 23 '17 at 8:44

# MY (noncompeting), 3 bytes

Here's the hex:

0A 49 27


Finally, a reasonable solution. Explanation:

0A - Push 10 to the stack
49 - Pop n; Push [1 ... n]
27 - Pop n; Output n


# Python 3, 24 bytes

print(list(range(1,11)))


Try it online!

# Python 2, 19 Bytes

print range(11)[1:]


Try it online!

# anyfix, 3 bytes

⁴RK


Note that TIO says that this is 5 bytes but that is because of the unicode character ⁴; in the codepage of anyfix (which is the same as the Jelly codepage), this solution encodes to 3 bytes.

## Explanation

⁴   10
R  Range [1..10]
K Join on spaces


Alternatively, ⁴RY separates by newlines. R⁴K and R⁴Y also work because one of the key features of anyfix is that it works with prefix, infix, and postfix (though K and Y will work regardless of what's on the stack because if the top of the stack is not a list or does not exist, then it will use the entire stack as a list). Alternatively, R⁴ or ⁴R and the @l interpreter flag will make it output [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]] because @l makes it output the stack as its string representation in Python.

Try it online!

# AnyDice, 10 bytes

output d10


Try it here.

This program creates and outputs a single 10 sided die. This lists out the numbers on the die (1-10) next to a bar graph of the probabilities in the standard output form.

# Eukleides, 26 bytes

for i=1 to 10
print i
end


Beats hardcoding by 2 bytes.

## T-SQL, 27 bytes

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


Less boring with a WHILE, 51 bytes

DECLARE @ INT=1WHILE @<11BEGIN PRINT @ SET @+=1 END


# ><>, 17 Bytes

1>:nao1\
;\?(b:+/


Pretty basic:

1                       | Push 1 to the stack
>                      | Make sure pointer is going the right direction
:n                    | Duplicate the number and print it
ao                  | Print a new line
1\                | Increment, redirect pointer
+/                |-┘
(b:                  | Check that the result is less than 11
;\?                     | If it is, continue looping, else end.


# Implicit, 10 bytes

(;.@%<10)&


Try it online!

(            do..while loop
;            pop (nothing initially, n<10 after that)
.           increment (0 initially, n after that)
@          output ASCII value of n for delimiter
%         output n as integer
<10      push n<10
)    loop while top of stack truthy (n<10)
&   exit (no implicit output)


Output (? denotes an unprintable):

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


# Bitwise, 208191 175 bytes

-17 bytes using the registers 3 and 4 instead of function frame registers
-16 bytes using position-based jumps instead of LABELs

.A:
AND $1$2 3
XOR $1$2 $1 SL 3 &1$2
JMP &-4 $2 RET$1
.G:
NOT $1 3 A$2 3 4
A 4 &1 4
SR 4 &31 4
AND 4 &1 4
RET 4
.L:
G $2$1 3
RET 3
A 1 &1 1
OUTI 1 &1
L 1 &10 2
JMP &-4 2


Try it online!

Explanation:

.A:          # subroutine: arg3 = arg1 + arg2
.G:          # subroutine: arg3 = arg1 > arg2
.L:          # subroutine: arg3 = arg1 < arg2
A 1 &1 1     # add l1 (literal 1) to r1 (register 1)
OUTI 1 &1 -1 # output r1 as integer
L 1 &10 2    # set r2 to r1 < 10
JMP &-4 2    # jump 3 lines back in the code if r2 is nonzero


Output:

1 2 3 4 5 6 7 8 9 10


# FALSE, 18 17 bytes

0[1+$11-][$."
"]#


Explanation:

0 {push 0}
{conditional function}
[
$11- {check if 11} ] {loop function} [$. {print number}
"
" {print line break}
]
# {while loop (run second function while first returns true)}


# Excel VBA, 20 Bytes

Anonymous VBE immediates window function that takes no input and outputs to the VBE Immediates window

For i=1To 10:?i:Next


# uBASIC, 20 bytes

Anonymous function that takes no input and outputs to the console

0Forx=1To10:?x:NextX


Try it online!

# Python3 - 19 Characters

print(*range(1,11))


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

# Rust, 42 bytes

fn main(){for i in 1..11{print!("{},",i)}}


# jamal, 17 characters

{@for i/1..10/i }


Sample run:

bash-4.4\$ jamal.pl number.jam
1 2 3 4 5 6 7 8 9 10


# Keg, 8 bytes

Still wasn't used to the flags...


Ï_(. ,


Try it online!

# Rogex, 27 bytes

90B300d00901e00100701a20f00


Try it online!

## Explained

90B 300 d00 # Set the loop value to 11
901         # Set the buffer to 1
e00         # While the buffer isn't equal to 11
100 701 # Print the buffer then increment it
a20     # Print a space
f00         # End loop


Rogex answer number 2! Also, my 101st answer! (´• ヮ •)

# MAWP, 13 bytes

25W[1A~!:1M~]


Try it!

• The integer complexity thing in 1+ is frustrating... – null Aug 13 '20 at 2:56
• yup lol, I should try golfing 1+ sometime – Razetime Sep 8 '20 at 6:44

# Rockstar, 32 bytes

X's0
while 10-X
let X be+1
say X
`

Try it here (Code will need to be pasted in)