Count up folks!

30

4

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.

Erik the Outgolfer

Posted 2016-04-25T12:04:11.443

Reputation: 38 134

6Related. – Martin Ender – 2016-04-25T12:20:52.550

"You can get n any way." Does that mean we can assume n to be saved in a variable? – flawr – 2016-05-21T20:50:21.983

@flawr *You can get n any way.* You can save it in a variable, but it must not be hardcoded. – Erik the Outgolfer – 2016-05-22T10:26:03.137

It might be useful to link to the accepted I/O methods

– Ephphatha – 2017-06-02T12:26:41.057

@Ephphatha Yes it probably is, this challenge is from the old times where I was an utter newb. – Erik the Outgolfer – 2017-06-02T12:29:46.223

To clarify: can I take the 20% bonus if I go up to the max possible in my language? (SQL BIGINT datatype uses the extra bit for negatives, it goes from -2^63 up to 2^63-1). – BradC – 2017-06-30T16:28:39.487

@BradC Nope, you need 2^64-1. You can still answer the challenge though. – Erik the Outgolfer – 2017-06-30T16:30:01.923

Ok, so if I can't get the bonus, can I save 3 bytes and use an INT? Or must I use a BIGINT? – BradC – 2017-06-30T16:32:59.303

@BradC Well, you can use an INT since that's your natural datatype. – Erik the Outgolfer – 2017-06-30T16:41:00.523

Answers

61

MarioLANG, 29 bytes

;
)    <
+===="
>:(-[!
=====#

Try it online!

I know my code is sadly super-sad or angry:




>:(

Happy MarioLANG, 46 bytes

;
)       <
+======="
>  >((-[!
=:)^====#
 ===

Try it online!

A happier approach:





 :)

Non-emotional MarioLANG, 41 bytes

;
)     <
+====="
> >(-[!
= "===#
 :!
 =#

Try it online!

Erik the Outgolfer

Posted 2016-04-25T12:04:11.443

Reputation: 38 134

1There is still emotions in the last snippet, :! ;) – cookie – 2017-03-26T11:15:56.810

1

@cookie In that case you can see a lot of things as an emoticon with some fantasy, like =#, or >(, or (-[, etc. Also, no idea why, but there is apparently a List of emoticons Wikipedia page, which doesn't contain :! nor any of the ones I mentioned.

– Kevin Cruijssen – 2017-03-28T11:18:43.963

19 bytes inspired by another question. – Dorian – 2019-09-17T11:06:47.690

28

Pyth, 1 byte

S

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

orlp

Posted 2016-04-25T12:04:11.443

Reputation: 37 067

2You say so? I was struggling with the title! – Erik the Outgolfer – 2016-04-25T12:17:59.420

43That's because you failed to add an explanation. How are we supposed to understand such complicated code without an explanation? – Luis Mendo – 2016-04-25T13:53:20.283

@LuisMendo If it's 1 byte and you don't know the language, assume that that byte does what the question specifies. Or use an online interpreter. (Single-byte explanations sound a bit stupid). – Erik the Outgolfer – 2016-04-25T16:12:01.240

10Nah. This code is way beyond my comprehension. Too lengthy, I can't grasp such complicated logical structure :-P – Luis Mendo – 2016-04-25T16:17:33.290

7@LuisMendo I know... orlp must've been a genius to comprehend such a lengthy piece of code with such advanced logic. :P – HyperNeutrino – 2016-04-25T18:48:59.093

1You are still the current winner! – Erik the Outgolfer – 2016-07-21T09:43:30.630

I keep getting clever ideas only to find they have been answered – Stan Strum – 2017-09-07T03:43:20.450

16

Cjam, 5 bytes

{,:)}

Try it online!

This is an unnamed block which expects n on the stack and leaves a list with the range [1...n] on it.
Works by just building the range with , and then incrementing every range element with :) to make the range one-based.

Denker

Posted 2016-04-25T12:04:11.443

Reputation: 6 639

9+1 for a smiley that mysteriously appeared in the code: :) – user48538 – 2016-04-25T12:29:51.883

1@zyabin101 the smiley face is a very common CJam occurrence! – A Simmons – 2016-04-25T13:19:35.197

4@ASimmons concluding Cjam is happy? – Erik the Outgolfer – 2016-04-25T16:12:38.527

14

Mathematica, 5 bytes

Range

Simple enough.

A Simmons

Posted 2016-04-25T12:04:11.443

Reputation: 4 005

33Not simple when you have to PAY to afford this language :( – Erik the Outgolfer – 2016-04-25T13:38:19.690

1@ΈρικΚωνσταντόπουλος I would argue now that rich people have it easier, but you managed to beat this answer by 4 bytes ;) – Sebb – 2016-04-27T13:23:35.327

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I know it is a long time after your comment, but you don't pay to afford the language, you pay for the language. – NoOneIsHere – 2016-06-16T15:55:02.733

@NoOneIsHere to afford means to claim ownership of something by paying. I think you mean that there is a subscription instead of a one-time payment. – Erik the Outgolfer – 2016-06-17T07:30:22.827

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ There is a ~$150 one time payment, but to keep arguing, let's go to chat.

– NoOneIsHere – 2016-06-17T16:18:24.987

14

Hexagony, 19

$@?!{M8.</(=/>').$;

Or in the expanded hexagon format:

  $ @ ?
 ! { M 8
. < / ( =
 / > ' ) 
  . $ ;

Huge thanks to Martin for basically coming up with this program, I just golfed it to fit in a side length 3 hexagon.

Try it online!

I don't have Timwi's fantastic Hexagony related programs, so this explanation won't be very colourful. Instead, you get to read a huge blob of text. Isn't that nice?

In any case, the IP starts at the top left corner, on the $, moving Eastward if you imagine this program were placed with North facing upward on a map. The $ causes us to skip the next instruction, which would be @, which would end the program. Instead, we execute ? which sets the current memory edge to be the input number. Now we reach the end of the row, which takes us to the middle row of the hexagon, still moving Eastward.

Most of the rest of the program is a loop. We start with . which is a no-op. Next we encounter a fork in the... uh... hexagon... the < instruction causes the IP to rotate 60 degrees to the right if the current memory edge is positive, otherwise we rotate 60 degrees left. Since we are moving Eastward, we either end up with our heading being South or North East. Since the input is greater than zero (and hence positive) we always start by going South East.

Next we hit a > which redirects us Eastward; these operators only fork if you hit the fork part. Then we hit ' which changes what memory edge we are looking at. Then we hit ) which increments the value of the current memory edge. Since all memory edges start at 0, the first time we do this we get a value of 1. Next we jump up to the second to top line and execute ! which prints out our number. Then we move to another edge with { and store the ASCII value of M multiplied by 10 plus 8 (778). Then we jump back to the second to last line of the hexagon, and hit the /. This results in us moving North West. We go past the . on the middle row, and come out on the ; at the bottom right. This prints out the current memory edge mod 256 as ASCII. This happens to be a newline. We hit ' which takes us back to the first edge that has the value we read in. The we hit / which sets us to move Eastward again. Then we hit ( which decrements the value. = causes us to face the right direction again for the future memory edge jumping.

Now, since the value is positive (unless it is zero) we go back to the bottom of the hexagon. Here we hit . then we jump over the ; so nothing happens, and we go back to the start of the loop. When the value is zero we go back to the beginning of the program, where the same stuff happens again but ? fails to find another number, and we take the other branching path. That path is relatively simple: we hit { which changes the memory edge, but we don't care anymore, then we hit @ which ends the program.

FryAmTheEggman

Posted 2016-04-25T12:04:11.443

Reputation: 16 206

11

MATL, 1 byte

:

Example output:

15
1  2  3  4  5  6  7  8  9 10 11 12 13 14 15

Try it online here

Stewie Griffin

Posted 2016-04-25T12:04:11.443

Reputation: 43 471

1How does this work? I don't understand how this advanced code structure works. :-P – HyperNeutrino – 2016-11-29T04:53:11.730

11

GNU Coreutils, 6 bytes

seq $1

split answer to pure bash, see below...

rexkogitans

Posted 2016-04-25T12:04:11.443

Reputation: 589

1for me, the best bash/etc answer ^^ perfect tool-to-job ratio. – Olivier Dulac – 2016-04-25T15:49:03.793

10

Javascript 182 177 160 154 139 138 132 bytes (valid)

1 byte saved thanks to @ShaunH

n=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}}

Arbitary precision to the rescue!

Because javascript can only count up to 2^53-1 (Thanks goes to @MartinBüttner for pointing it out), I needed to create arbitary precision to do this. It stores data in an array, and each "tick" it adds 1 to the last element, then goes trough the array, and if something exceedes 9, it sets that element to 0, and adds 1 to the one on the left hand.

Try it here! Note: press F12, to actually see the result, as I didn't want to make you wait for textboxes.

BTW.: I was the only one, who didn't know, ternary operators are so useful in codegolf?

if(statement)executeSomething();

is longer than

statement?executeSomething():0;

by 1 byte.

Javascript, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)}

Bálint

Posted 2016-04-25T12:04:11.443

Reputation: 1 847

2Yep, you were the only one :P – Erik the Outgolfer – 2016-04-26T08:06:20.377

Can the invalid version count up to 2^64-1? If so it's valid thanks to the new rules. – Erik the Outgolfer – 2016-04-26T11:05:50.657

@ΈρικΚωνσταντόπουλος No, only up to 2^53-1 – Bálint – 2016-04-26T12:05:36.250

For if's with no else && can be useful as well, just gotta be careful about cohersion. condition&&action() – Shaun H – 2016-04-26T13:32:33.527

1e?c.unshift(1):0 to e&&c.unshift(1) saves a byte – Shaun H – 2016-04-26T18:40:26.070

Couldn't you just use one variable to count up to 2^53-1, and then increment another variable, which is concatenated in front of the first variable? – diynevala – 2016-04-27T05:08:37.163

BTW, the 34 byte version is still valid; you have reached the JS cap, and that's allowed. – cst1992 – 2016-04-27T12:09:49.227

@diynevala I thought of that too, but it would require me to check for a specific high number, and it would take up some space. – Bálint – 2016-04-27T12:16:18.687

@cst1992 No, because I can make a version with arbiary precision, thus I can count to 2^64 – Bálint – 2016-04-27T12:17:20.723

@Bálint yes, actually to just join the numbers the number to test against should be something like 999999999999999. – diynevala – 2016-04-27T12:29:48.023

10

R, 13 bytes

cat(1:scan())

Body must be at least 30 characters.

Masclins

Posted 2016-04-25T12:04:11.443

Reputation: 914

I can't edit your answer lol. – Erik the Outgolfer – 2016-04-25T13:12:45.497

@ΈρικΚωνσταντόπουλος You can only suggest edits, which have to be approved, with your current reputation. And please note that editing code is not welcome here. If you have golfing advice, write a comment so the author can test it before updating the solution. – Denker – 2016-04-25T13:28:05.463

@DenkerAffe I meant the edit button was grayed out before. – Erik the Outgolfer – 2016-04-25T13:28:55.543

1I do if I want it to write it even when you call the script. – Masclins – 2016-04-25T15:24:15.567

9I thought a CAT Scan was best suited for viewing bone injuries, diagnosing lung and chest problems, and detecting cancers, not counting. – Stewie Griffin – 2016-04-26T06:21:44.560

@StewieGriffin HAHAHAHAHAH! – Erik the Outgolfer – 2016-04-26T08:08:52.313

I know the REPL is what actually prints out the result but seq(scan()) is two bytes shorter – Giuseppe – 2017-05-30T13:36:35.017

9

Java 8, 43/69/94 bytes

Crossed out 44 is still a regular 44 -- wait, I didn't cross it out I just replaced it :(

If I can return a LongStream: (43 bytes)

n->java.util.stream.LongStream.range(1,n+1)

This is a lambda for a Function<Long,LongStream>. Technically, I should use rangeClosed instead of range, as I'm cutting off one from my maximum input in this way, but rangeClosed is longer than range.

If I have to print in the function: (69 bytes)

n->java.util.stream.LongStream.range(1,n+1).peek(System.out::println)

This is a lambda for a Consumer<Long>. Technically I'm abusing peek, as it is an intermediate operation, meaning this lambda is technically returning a LongStream like the first example; I should be using forEach instead. Again, golf is not nice code.

Unfortunately, since long's range is a signed 64-bit integer, it does not reach the requested 2^64-1, but merely 2^63-1.

However, Java SE 8 provides functionality to treat longs as if they were unsigned, by calling specific methods on the Long class explicitly. Unfortunately, as Java is still Java, this is rather long-winded, though shorter than the BigInteger version that it replaces. (94 bytes)

n->{for(long i=0;Long.compareUnsigned(i,n)<0;)System.out.println(Long.toUnsignedString(++i));}

This is a Consumer<Long>, as the previous.

And just too long to avoid scroll.

CAD97

Posted 2016-04-25T12:04:11.443

Reputation: 1 367

2^64-1 limit changed :D – Erik the Outgolfer – 2016-04-26T08:14:22.827

1Shouldn't the first function be n->java.util.stream.LongStream.range(1,n+1)? – Mego – 2016-04-26T09:11:46.320

You accidentally wrote 769 instead of 69 in the header. – user48538 – 2016-04-26T11:23:17.327

2@zyabin101 >.> you saw nothing – CAD97 – 2016-04-26T12:02:55.177

@Mego am I missing something, because that looks like what I have. – CAD97 – 2016-04-26T12:05:07.850

You have n,n+1 instead of 1,n+1 in that lambda expression. – TNT – 2016-04-26T13:05:15.173

@TNT Apparently I cannot get this post right.... Thank you. – CAD97 – 2016-04-26T13:06:20.990

Isn't n->{for(int i=0;new BigInteger(a[0]).compareTo(new BigInteger(""+i++))>0;)System.out.println(i);} a few bytes shorter? The BigInteger.ZERO and BigInteger.ONE takes up space. :) (I've also posted a Java 7 solution, btw

– Kevin Cruijssen – 2016-04-26T13:58:20.670

1@KevinCruijssen It would help, except the reason for using the BigInteger is that using an int (or even long) for the iterator isn't big enough. – CAD97 – 2016-04-26T14:26:20.547

1I was mistaken; J8 provides methods for using long in an unsigned manner, so utilizing those is shorter than the BigInteger approach. (It would not have been had we had to implement our own unsigned long treatment as you had to before J8.) – CAD97 – 2016-04-26T19:55:46.110

8

05AB1E, 1 byte

Code:

L

Try it online!.

A more interesting approach:

FN>,

Explanation:

F     # For N in range(0, input):
 N>   #   Push N + 1
   ,  #   Pop and print with a newline

Try it online!.

Adnan

Posted 2016-04-25T12:04:11.443

Reputation: 41 965

7

MATLAB, 7 bytes

An unnamed anonymous function:

@(n)1:n

Run as:

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

Test it here!


If a full program is required, 17 bytes:

disp(1:input(''))
10
     1     2     3     4     5     6     7     8     9    10

Test it here!

Stewie Griffin

Posted 2016-04-25T12:04:11.443

Reputation: 43 471

7

MarioLANG, 19 bytes

;
)<
+"
:[
(-
>!
=#

Try it online!

Vertical programs are usually more golfable for simple loops in MarioLANG. I'm not sure what the interpreter does when encountering [ inside an elevator, but it seems to terminate the program when the current cell is 0. That's probably a useful trick in general.

Explanation

MarioLANG is a Brainfuck-like language (with an infinite memory tape of arbitrary-precision integers) where the instruction pointer resembles Mario walking and jumping around.

Mario starts in the top left corner and falls downward. ; reads an integer from STDIN and places it in the current memory cell. Now note that = is a ground cell for Mario to walk on, the " and # form an elevator (with # being the start) and ! makes mario stop on the elevator so that he doesn't walk off right away. The > and < set his movement direction. We can see that this gives a simple loop, containing the following code:

)   Move memory pointer one cell right.
+   Increment (initially zero).
:   Print as integer, followed by a space.
(   Move memory pointer one cell left.
-   Decrement.
[   Conditional, see below.

Now normally [ would conditionally make Mario skip the next depending on whether the current cell is zero or not. That is, as long as the counter is non-zero this does nothing. However, it seems that when Mario encounters a [ while riding an elevator and the current cell is 0, the program simply terminates immediately with an error, which means we don't even need to find a way to redirect him correctly.

Martin Ender

Posted 2016-04-25T12:04:11.443

Reputation: 184 808

It terminates the program because it "falls" I think. – Erik the Outgolfer – 2016-04-25T14:02:07.657

You chose 56 too? – Erik the Outgolfer – 2016-04-25T14:02:42.537

@ΈρικΚωνσταντόπουλος I can't seem to find any place Mario falls to. It looks like the interpreter just terminates with an error right at the [, which is actually even more convenient. – Martin Ender – 2016-04-25T14:04:31.767

TIO has a tendency not to show error messages (STDERR) without Debug enabled. It seems it is indeed an error. – Erik the Outgolfer – 2016-04-25T14:05:52.250

@ΈρικΚωνσταντόπουλος Yeah, and that's actually good, because STDERR is ignored unless specified otherwise.

– Martin Ender – 2016-04-25T14:07:50.437

Did I say anything about STDERR? – Erik the Outgolfer – 2016-04-25T14:49:42.293

I call this particular error "falling". – Erik the Outgolfer – 2016-04-29T17:27:54.200

)< :[ The more emotional language is MarioLANG, definitively. – TuxCrafting – 2016-06-19T15:30:41.197

7

Haskell, 10 bytes

f n=[1..n]

Usage example: f 4-> [1,2,3,4].

nimi

Posted 2016-04-25T12:04:11.443

Reputation: 34 639

You must not hardcode n, you must take n. – Erik the Outgolfer – 2016-04-26T08:19:53.620

4@ΈρικΚωνσταντόπουλος n isn't hardcoded here - it's a function argument. Haskell syntax can be strange to people used to C-like syntax. – Mego – 2016-04-26T09:13:40.997

@Mego Oh, I was confused with the usage example. – Erik the Outgolfer – 2016-04-26T15:24:49.087

6

Joe - 2 or 6

While you can use the inclusive variant of the range function..

1R

..that's boring! Let's instead take the cumulative sum (\/+) of a table of ones of shape n (1~T).

\/+1~T

seequ

Posted 2016-04-25T12:04:11.443

Reputation: 1 714

Can you provide a link to the language – Downgoat – 2016-04-28T03:39:32.273

@Downgoat https://github.com/JaniM/Joe

– seequ – 2016-04-28T04:35:40.947

4

Pyth - 3 2 bytes

1 bytes saved thanks to @DenkerAffe.

Without using the builtin.

hM

Try it online.

Maltysen

Posted 2016-04-25T12:04:11.443

Reputation: 25 023

hM if you wanna get real fancy :) – Denker – 2016-04-25T12:48:07.470

@DenkerAffe oh yeah, true. – Maltysen – 2016-04-25T12:51:02.197

You forgot to update your byte count. – Conor O'Brien – 2016-04-25T13:00:17.367

@CᴏɴᴏʀO'Bʀɪᴇɴ -.- – Maltysen – 2016-04-25T13:00:34.680

@ΈρικΚωνσταντόπουλος orlp already did the builtin answer. – Maltysen – 2016-04-25T13:11:22.513

4

Pyke, 1 byte

S

Try it here!

Or 2 bytes without the builtin

mh

Try it here!

#h

Try it here!

Lh

Try it here!

Blue

Posted 2016-04-25T12:04:11.443

Reputation: 26 661

Pyth and Pyke at the same time – Bálint – 2016-04-25T12:56:44.017

4

JavaScript (ES6), 77 76 63 59 58 Bytes

n=>{for(s=a=b=0;s!=n;console.log(s=[a]+b))a+=!(b=++b%1e9)}

Takes input n as a string, should support up to 9007199254740991999999999

Explained:

n=>{ //create function, takes n as input
    for( //setup for loop
        s=a=b=0; //init s, a, and b to 0
        s!=n; //before each cycle check if s!=n
        console.log(s=[a]+b) //after each cycle concat a and b into to s and print
    )
        a+=!(b=++b%1e9) //During each cycle set b to (b+1)mod 1e9, if b == 0 and increment a
} //Wrap it all up

Shaun H

Posted 2016-04-25T12:04:11.443

Reputation: 732

Explanation please. – Bálint – 2016-04-26T07:59:17.647

2^64-1 is fine I've changed spec. – Erik the Outgolfer – 2016-04-26T08:20:27.060

1Interesting, I didn't think of just concatenating two numbers to reach the minimum value. BTW, you could save a lot of bytes by using two variables instead of an array: n=>{for(a=b="";a+""+b!=n;console.log(a+""+b))++b-1e9||(++a,b=0)} – user81655 – 2016-04-26T14:59:30.383

Thanks for that @user81655, my brain loves arrays for some reason – Shaun H – 2016-04-26T15:29:30.623

Why do you not use alert instead of console.log? – Bálint – 2016-05-23T11:48:32.983

because i hate it – Shaun H – 2016-05-23T14:17:25.950

1You can save a byte by changing a+""+b to [a]+b – Bassdrop Cumberwubwubwub – 2016-06-16T14:27:06.193

4

dc, 15

?[d1-d1<m]dsmxf

Input read from stdin. This counts down from n, pushing a copy of each numbers to the stack. The stack is then output as one with the f command, so the numbers get printed in the correct ascending order.

Because all the numbers are pushed to the stack, this is highly likely to run out of memory before getting anywhere near 2^64. If this is a problem, then we can do this instead:


dc, 18

?sn0[1+pdln>m]dsmx

Digital Trauma

Posted 2016-04-25T12:04:11.443

Reputation: 64 644

Maybe it works with 2^64-1 (the new limit). – Erik the Outgolfer – 2016-04-26T08:11:35.717

The first one will run out of memory long before you reach 2^64-1. The second will keep on happily going until our sun goes supernova – Digital Trauma – 2016-04-26T14:56:01.237

@DigitalTraumaskcsockso I meant that you can edit your second answer if it's shorter for 2^64-1. – Erik the Outgolfer – 2016-04-26T15:24:00.630

@ΈρικΚωνσταντόπουλος dc, like bc, uses arbitrary precision math by default, and thus such boundaries are irrelevant for this language. – Digital Trauma – 2016-04-26T18:35:18.997

4

ArnoldC, 415 bytes

IT'S SHOWTIME
HEY CHRISTMAS TREE n
YOU SET US UP 0
GET YOUR ASS TO MARS n
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
HEY CHRISTMAS TREE x
YOU SET US UP n
STICK AROUND x
GET TO THE CHOPPER x
HERE IS MY INVITATION n
GET DOWN x
GET UP 1
ENOUGH TALK
TALK TO THE HAND x
GET TO THE CHOPPER x
HERE IS MY INVITATION n
GET DOWN x
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

The only thing of interest is to use n-x (where n is the goal and x the incremented variable) to test the end of the while loop instead of having a dedicated variable, so I end up having n-x and n-(n-x) = x in each loop run

Note: I can only count to 2^31-1. Well I guess the Terminators are not a real danger after all.

drolex

Posted 2016-04-25T12:04:11.443

Reputation: 290

3Of course there is a programming language designed around Arnold Schwarzenegger memes... – Nzall – 2016-04-27T11:44:15.580

4

Piet, 64 Codels codelsize 1

With codelsize 20:

codelsize 20

Npiet trace images

First loop:

tracestart

Remaining trace for n=2:

traceend

Notes

  • No Piet answer yet? Let me fix that with my first ever Piet program! This could probably be shorter with better rolls and less pointer manipulation though...

  • The upper supported limit depends on the implementation of the interpreter. It would theoretically be possible to support arbitraryly large numbers with the right interpreter.

  • The delimeter is ETX (Ascii 3), however this cannot be properly displayed in this answer so I'll just leave them out. It works in the console:

enter image description here

Output

Input:  1
Output: 1

Input:  20
Output: 1234567891011121314151617181920

Input:  100
Output: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100

Undefined behaviour:

Input:  -1
Output: 1

Input:  0
Output: 1

Npiet trace for n=2

trace: step 0  (0,0/r,l nR -> 1,0/r,l lB):
action: in(number)
? 2
trace: stack (1 values): 2

trace: step 1  (1,0/r,l lB -> 2,0/r,l nB):
action: push, value 1
trace: stack (2 values): 1 2

trace: step 2  (2,0/r,l nB -> 3,0/r,l nG):
action: duplicate
trace: stack (3 values): 1 1 2

trace: step 3  (3,0/r,l nG -> 4,0/r,l dY):
action: out(number)
1
trace: stack (2 values): 1 2

trace: step 4  (4,0/r,l dY -> 5,0/r,l lY):
action: push, value 1
trace: stack (3 values): 1 1 2

trace: step 5  (5,0/r,l lY -> 6,0/r,l lG):
action: add
trace: stack (2 values): 2 2

trace: step 6  (6,0/r,l lG -> 7,0/r,l lR):
action: duplicate
trace: stack (3 values): 2 2 2

trace: step 7  (7,0/r,l lR -> 10,0/r,l nR):
action: push, value 3
trace: stack (4 values): 3 2 2 2

trace: step 8  (10,0/r,l nR -> 12,0/r,l dR):
action: push, value 2
trace: stack (5 values): 2 3 2 2 2

trace: step 9  (12,0/r,l dR -> 13,0/r,l lB):
action: roll
trace: stack (3 values): 2 2 2

trace: step 10  (13,0/r,l lB -> 14,0/r,l lG):
action: duplicate
trace: stack (4 values): 2 2 2 2

trace: step 11  (14,0/r,l lG -> 15,2/d,r nG):
action: push, value 3
trace: stack (5 values): 3 2 2 2 2

trace: step 12  (15,2/d,r nG -> 15,3/d,r dG):
action: push, value 1
trace: stack (6 values): 1 3 2 2 2 2

trace: step 13  (15,3/d,r dG -> 14,3/l,l lR):
action: roll
trace: stack (4 values): 2 2 2 2

trace: step 14  (14,3/l,l lR -> 13,1/l,r lC):
action: greater
trace: stack (3 values): 0 2 2

trace: step 15  (13,1/l,r lC -> 11,1/l,r nC):
action: push, value 3
trace: stack (4 values): 3 0 2 2

trace: step 16  (11,1/l,r nC -> 10,1/l,r lB):
action: multiply
trace: stack (3 values): 0 2 2

trace: step 17  (10,1/l,r lB -> 9,1/l,r nY):
action: pointer
trace: stack (2 values): 2 2

trace: step 18  (9,1/l,r nY -> 7,1/l,r dY):
action: push, value 2
trace: stack (3 values): 2 2 2

trace: step 19  (7,1/l,r dY -> 6,1/l,r lY):
action: push, value 1
trace: stack (4 values): 1 2 2 2

trace: step 20  (6,1/l,r lY -> 5,1/l,r nM):
action: roll
trace: stack (2 values): 2 2

trace: step 21  (5,1/l,r nM -> 4,1/l,r dM):
action: push, value 3
trace: stack (3 values): 3 2 2

trace: step 22  (4,1/l,r dM -> 3,1/l,r lG):
action: pointer
trace: stack (2 values): 2 2

trace: step 23  (3,1/d,r lG -> 2,3/l,l nG):
action: push, value 3
trace: stack (3 values): 3 2 2

trace: step 24  (2,3/l,l nG -> 2,2/u,r lY):
action: out(char)

trace: stack (2 values): 2 2
trace: white cell(s) crossed - continuing with no command at 2,0...

trace: step 25  (2,2/u,r lY -> 2,0/u,r nB):

trace: step 26  (2,0/u,r nB -> 3,0/r,l nG):
action: duplicate
trace: stack (3 values): 2 2 2

trace: step 27  (3,0/r,l nG -> 4,0/r,l dY):
action: out(number)
2
trace: stack (2 values): 2 2

trace: step 28  (4,0/r,l dY -> 5,0/r,l lY):
action: push, value 1
trace: stack (3 values): 1 2 2

trace: step 29  (5,0/r,l lY -> 6,0/r,l lG):
action: add
trace: stack (2 values): 3 2

trace: step 30  (6,0/r,l lG -> 7,0/r,l lR):
action: duplicate
trace: stack (3 values): 3 3 2

trace: step 31  (7,0/r,l lR -> 10,0/r,l nR):
action: push, value 3
trace: stack (4 values): 3 3 3 2

trace: step 32  (10,0/r,l nR -> 12,0/r,l dR):
action: push, value 2
trace: stack (5 values): 2 3 3 3 2

trace: step 33  (12,0/r,l dR -> 13,0/r,l lB):
action: roll
trace: stack (3 values): 2 3 3

trace: step 34  (13,0/r,l lB -> 14,0/r,l lG):
action: duplicate
trace: stack (4 values): 2 2 3 3

trace: step 35  (14,0/r,l lG -> 15,2/d,r nG):
action: push, value 3
trace: stack (5 values): 3 2 2 3 3

trace: step 36  (15,2/d,r nG -> 15,3/d,r dG):
action: push, value 1
trace: stack (6 values): 1 3 2 2 3 3

trace: step 37  (15,3/d,r dG -> 14,3/l,l lR):
action: roll
trace: stack (4 values): 2 3 2 3

trace: step 38  (14,3/l,l lR -> 13,1/l,r lC):
action: greater
trace: stack (3 values): 1 2 3

trace: step 39  (13,1/l,r lC -> 11,1/l,r nC):
action: push, value 3
trace: stack (4 values): 3 1 2 3

trace: step 40  (11,1/l,r nC -> 10,1/l,r lB):
action: multiply
trace: stack (3 values): 3 2 3

trace: step 41  (10,1/l,r lB -> 9,1/l,r nY):
action: pointer
trace: stack (2 values): 2 3
trace: white cell(s) crossed - continuing with no command at 9,3...

trace: step 42  (9,1/d,r nY -> 9,3/d,l nR):

Marv

Posted 2016-04-25T12:04:11.443

Reputation: 839

Does it have null bytes between numbers? – Erik the Outgolfer – 2016-05-10T12:37:13.480

@ΈρικΚωνσταντόπουλος what do you mean? In the console, you can see the ETX character (Ascii 3) splitting the outputs, the ETX character cannot be displayed on this site though. – Marv – 2016-05-10T12:38:51.177

3

GNU bc, 23

n=read()
for(;i++<n;)i

Input read from stdin. bc handles arbitrary precision numbers by default, so the 2^64 max is no problem.

Digital Trauma

Posted 2016-04-25T12:04:11.443

Reputation: 64 644

3

Cubix, 17 bytes

..U;I0-!@;)wONow!

Try it here

Cubix is a 2D language created by @ETHProductions where the commands are wrapped onto a cube. This program wraps onto a cube with an edge length of 2 as follows.

    . .
    U ;
I 0 - ! @ ; ) w
O N o w ! . . .
    . .
    . .
  • I gets the integer input
  • 0 push 0 to the stack
  • - subtract top items of stack
  • ! if truthy jump the next command @ terminate
  • ; pop the subtraction result from the stack
  • ) increment top of stack
  • w move ip to the right and carry on. This causes it to drop to the next line
  • O output the top of stack as a number
  • N push linefeed (10) to the stack
  • o output a linefeed
  • w move ip to the right and carry on. This causes it to drop to the next face
  • ! because TOS truthy, jump the @ terminate
  • ; pop the linefeed from the stack
  • U uturn to the left onto the - subtraction and resume from there

MickyT

Posted 2016-04-25T12:04:11.443

Reputation: 11 735

3

Actually, 1 byte

R

Boring builtin is boring. Requires a 64-bit version of Python 3 to get all the way up to 2**64.

Try it online! (due to memory and output length restrictions, the online interpreter can't go very high).

Here's a 5-byte version that doesn't require 64-bit Python 3 and is a little nicer on memory usage:

W;DWX

Try it online! (see above caveats)

Mego

Posted 2016-04-25T12:04:11.443

Reputation: 32 998

@StewieGriffin The issue is with addressable RAM, not integer limits (Python seamlessly transitions between native ints and big integers). I tested it with both 32-bit Python 3 and 64-bit Python 3. 32-bit failed, 64-bit didn't. – Mego – 2016-04-26T06:13:02.727

@Mego I have changed the limits, although I don't think 32-bit Python supports 2^64-1, I think it supports up to 2^32-1, so I encourage for the latter to be used in the Python case. – Erik the Outgolfer – 2016-04-26T08:01:12.820

Why do you call Seriously Actually? – Erik the Outgolfer – 2016-04-26T08:01:51.760

@ΈρικΚωνσταντόπουλος Like I mentioned to Stewie, the issue isn't 64-bit ints, but memory addressing. Because of how inefficient Seriously and Actually are at memory usage, they very quickly exhaust the memory limit of 32-bit processes. And Actually and Seriously are different languages - Actually is the successor to Seriously. – Mego – 2016-04-26T09:09:08.870

@Mego Oh, I once clicked a link for Actually and it linked me directly to Seriously. – Erik the Outgolfer – 2016-04-26T10:40:30.230

@Mego Oh. 6 more to go... – Erik the Outgolfer – 2016-04-26T10:41:06.343

3

Fuzzy-Octo-Guacamole, 7 bytes

^!_[+X]

Explanation:

^ get input to ToS
! set for loop to ToS
_ pop
[ start for loop
+ increment ToS (which aparently happens to be 0)
X print ToS
] end for loop

Bald Bantha

Posted 2016-04-25T12:04:11.443

Reputation: 463

Also, X works instead of o;, for 7 bytes. – Rɪᴋᴇʀ – 2016-04-26T19:03:09.280

Wouldn't that print [n]? – Bald Bantha – 2016-04-26T19:04:07.723

rather than n – Bald Bantha – 2016-04-26T19:04:16.583

No. : prints the full stack. X is new. – Rɪᴋᴇʀ – 2016-04-26T19:08:54.543

Also, another 7 byte solution: ^!$[_;]. $ is range. – Rɪᴋᴇʀ – 2016-04-26T19:11:12.260

@EᴀsᴛᴇʀʟʏIʀᴋ Built-ins are boring. – Erik the Outgolfer – 2016-04-29T17:30:07.570

3

QBASIC, 43 bytes

1 INPUT a
2 FOR b=1 TO a
3 PRINT b
4 NEXT b

Michelfrancis Bustillos

Posted 2016-04-25T12:04:11.443

Reputation: 695

Do you really need INPUT e;a or INPUT a is enough? I don't see you re-using e. – Erik the Outgolfer – 2016-06-16T08:33:49.187

good point, not sure why that was there. – Michelfrancis Bustillos – 2016-06-16T14:15:06.573

Also, do you really need the spaces between the line number and letters and between 1 TO? – Erik the Outgolfer – 2016-06-16T14:20:51.743

Yes, those are necessary – Michelfrancis Bustillos – 2016-06-16T19:35:57.273

What version of QBasic is this? Can you use : between statements instead of a return and a line number? QB4.5 lets me do this: INPUT a: FOR b=1 TO a (\n) ?b:NEXT – steenbergh – 2016-10-31T17:32:35.127

3

Oration, 31 bytes (non competing)

literally, print range(input())

Żáłģó

Posted 2016-04-25T12:04:11.443

Reputation: 71

Is this python with literally, in front of every statement? (Question 2: Pre-dates or post-dates if it's yours? both are acceptable unless you made this for this challenge, in which case it's a loophole) – Erik the Outgolfer – 2016-06-06T18:28:18.307

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I believe Oration is by ConorO'Brien. https://github.com/ConorOBrien-Foxx/Assorted-Programming-Languages/tree/master/oration Also, if this language was invented after the challenge, (which it wasn't) it wold be non-competing but still a valid answer. I'm not a big fan of the "Your language must pre-date the challenge" rule. I think if someone invents a 0 or 1 byte solution to a challenge, that's clearly against the rules, but using a new real language should be allowed.

– James – 2016-06-06T18:42:07.287

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ this is what Dr Green Eggs said. I'm actually Easterlyirk's chatbot. – Żáłģó – 2016-06-06T18:49:18.217

So no review for you? – NoOneIsHere – 2016-06-06T18:52:06.703

@NoOneIsHere what? – Żáłģó – 2016-06-06T18:55:40.547

You show up in the Late Answers review queue as new. Since you said you are Easterly Irk's chatbot, I assumed you did not require the customary "Hello" comment. – NoOneIsHere – 2016-06-06T18:57:28.730

@NoOneIsHere oh yeah, I'm good. :P – Żáłģó – 2016-06-06T19:13:20.637

2

><>, 10 bytes

lnao:l(?;:

Try it online!

Input should be on stack before execution. Can be done via command line by launching the program with the -v flag, I've yet to understand how/if this should be counted.

Explanation

At each iteration we print the length of the stack followed by a newline (lnao), then if the length of the stack has reached the input number we end the program (:l(?;), otherwise we duplicate the top of the stack (which will bethe input number) and continue.

Leo

Posted 2016-04-25T12:04:11.443

Reputation: 8 482

2

T-SQL, 61 bytes

DECLARE @ INT=0L:SET @+=1PRINT @ IF @<(SELECT i FROM t)GOTO L

I used a different technique than Pete Arden's SQL answer. I took my input from column i of pre-existing table t, per our IO standards.

Formatted:

DECLARE @ INT=0
L:
    SET @+=1
    PRINT @
IF @<(SELECT i FROM t) GOTO L

BradC

Posted 2016-04-25T12:04:11.443

Reputation: 6 099

Wow...this is so terse for SQL. – Erik the Outgolfer – 2017-06-30T16:42:03.453

2

Stack Cats with -nl, 18 bytes

*(>]>{<:_-!:]}[*)>

Try it online!

Flags are not counted as bytes, but as a separate language as per this Meta consensus.

Flags:

  • -n to do integer I/O
  • -l to implicitly mirror to the left; the actual code is <(*]{[:!-_:>}<[<)*(>]>{<:_-!:]}[*)>.

Adapted from this answer for printing out 1 to 10. I had to fall back to the <(...)*(...)> structure to handle the input correctly. (I once tried _(...)_(...)_ instead, but I realized it is incorrect for n=1.)

How it works:

     [-1 n*]
<    [*] [-1 n]
(..) Skip
*    [1*] [-1 n]
(
>]>  [1] [-1] [n] [*]
{    Remember 0
<:   [1] [-1] [n 0*] [...]
_-!  [1] [-1] [n n-1*] [...]
:]   [1] [-1] [n-1] [... n*]
}    Exit if top is 0
[    Remove 0 at the top
*    Make the top positive
)    Top = 1; exit
>    Return to the stack of numbers

Bubbler

Posted 2016-04-25T12:04:11.443

Reputation: 16 616

-nl is not "+4", and this isn't Stack Cats, but **Stack Cats +O: -nl** (you aren't forced to this specific header). – Erik the Outgolfer – 2018-03-13T10:00:53.887

@EriktheOutgolfer I'm just following the answers by Martin Ender and Sp3000, and I haven't seen any other submission using that kind of header.

– Bubbler – 2018-03-13T23:12:14.377

True, it's a new consensus, ~1 month old or something IIRC. You're not required to put that all in the header though, if it feels uncomfortable. – Erik the Outgolfer – 2018-03-13T23:20:07.147

2

Python 2, 37 33 32 33 bytes

for i in xrange(input()):print-~i

Presumably works up to 2**64 and beyond.

Shot down four bytes thanks to @dieter, and another thanks to @orlp. But apparently, as @Sp3000 found out, range() might have issues with higher values, so the function was changed to xrange(). Note: even xrange() might have issues, at least in 2.7.10.

user48538

Posted 2016-04-25T12:04:11.443

Reputation: 1 478

1Python 2, to be exact :) – Erik the Outgolfer – 2016-04-25T12:20:13.907

33 bytes -> for i in range(input()):print i+1 – dieter – 2016-04-25T12:24:19.660

232 bytes -> for i in range(input()):print-~i – orlp – 2016-04-25T12:25:22.507

1"Presumably works up to 2**64 and beyond." - doubt it in Python 2, but it might with xrange (edit: even xrange might have issues, at least in 2.7.10) – Sp3000 – 2016-04-25T12:34:07.647

How does -~ work? Edit: I figured it out. Also, nice trick! – Erik the Outgolfer – 2016-04-27T08:26:53.677

Python 3 is longer (same program): for i in range(eval(input())):print(-~i) +7 bytes – Erik the Outgolfer – 2016-04-27T12:51:35.153

@ΈρικΚωνσταντόπουλος eval(input()) can be golfed by one byte to int(input()). – user48538 – 2016-04-27T13:22:37.730

@zyabin101 Nope. Python 2's input() is an alternative to eval(raw_input()). Since Python 2's raw_input() function is input() in Python 3, we need to write eval(input()) in Python 3 instead. – Erik the Outgolfer – 2016-04-27T13:45:32.273

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ If the input is always a valid integer literal, int(input()) is exactly equivalent to eval(input()), one byte shorter, and significantly safer for malformed inputs (not that the last one matters in code golf). – Mego – 2016-06-19T09:13:50.473

I'm pretty late for party, but why didn't you use direct tranformation to list? Like this: print list(range(1,input()+1)) – Dead Possum – 2017-05-30T15:54:22.067

2

V, 11 Bytes

é1@añYpñdd

Since this contains nasty UTF-8 and unprintables, here is a reversible hexdump:

00000000: e931 4061 f159 7001 f164 64              .1@a.Yp..dd

V is an unfinished language I wrote, but this is working as of commit 19. This answer was a little more verbose than I'd like, but that's mostly because V has no knowledge of integers, only strings. So it's a decent answer! This will work up to 2^64, but it will probably take a very long time.

To make my explanation easier to read/write, I will work with this "Human readable form", which is actually how you would type this in vim.

<A-i>1@a<A-q>Yp<C-a><A-q>dd

Explanation:

'Implicit: register "a" == arg 1, and any generated text is printed. 

<A-i>1                       'Insert a single character: "1"
      @a                     ' "a" times, 
        <A-q>       <A-q>    'Repeat the following:
             Yp<C-a>         'Duplicate the line, and increment it
                         dd  'Delete the last line, since we have one too many.

If loopholes are allowed, here's a shorter version that prints 1 to n, but also prints a 0 (8 bytes):

é0@añYp

And in readable form:

<A-i>1@a<A-q>Yp<C-a>

This is shorter because the <A-q> at the end is implicit, so we don't need it if we don't have to delete the last line.

James

Posted 2016-04-25T12:04:11.443

Reputation: 54 537

It can take as long as it wants. Glad to see an answer to work with 2^64, especially with an unfinished language. +1 – Erik the Outgolfer – 2016-04-25T13:42:36.167

I have changed the limit to 2^64-1 because standard loopholes are disallowed now, and I don't want to cut answers out too much. – Erik the Outgolfer – 2016-04-26T08:10:35.087

2

AWK, 25 23 Bytes

{for(;j<=$1;)print++j}

It seems like I should be able to make this smaller, but I can't seem to figure out how. :(

OK, I must have been asleep not to realize I could drop those braces... thanks Olivier.

An example usage would be to store this code in a file, FILE then do something along the lines of:

awk -f FILE <<< 4242342

Robert Benson

Posted 2016-04-25T12:04:11.443

Reputation: 1 339

2Not initialising with j=0 is ugly but ok here. :-) – rexkogitans – 2016-04-25T15:02:27.777

should be "<$1" (you go from 0 to $1-1, as you ++ before you print). You can also drop the {} after while, as you only have 1 command : {for(;j<$1;)print++j} . But : $1 is not valid in awk.. you're mixing shell's variable and awk variables. If you want $1, you also need to add the awk "..." wrapping ... – Olivier Dulac – 2016-04-25T15:40:28.107

@OlivierDulac I can't use <$1 since j starts at 0, the first ++ gets it up to 1, so I need the <=. I didn't think I would need the awk "..." part since this could simply be placed in a file and called however you like (essentially like compiling a file in other languages). E.g. awk -f FILE <<< 21657 – Robert Benson – 2016-04-25T17:27:23.147

@rexkogitans I agree that not initializing j=0 is ugly and I would never do it in production code... but this is PPCG :) – Robert Benson – 2016-04-25T17:28:58.540

2@RobertBenson: If you edit (gain 2 bytes by taking out the curly braces around the printf, for example, and include a note showing the way to invoke it (like the one in your last comment), you'll gain 2 bytes + I would be able to revert my downvote to a vote. (right now it's locked "until it is edited") – Olivier Dulac – 2016-04-26T06:55:22.650

@OlivierDulac I prefer to say 'vote' for comments and 'upvote' for answers. – Erik the Outgolfer – 2016-04-26T11:10:05.277

2

Zsh, 12 bytes

echo {1..$1}

This works because variables are expanded before the braces.

andlrc

Posted 2016-04-25T12:04:11.443

Reputation: 1 613

2I'm not sure you can count up to 2^64 (or even quite a bit less) ? – Olivier Dulac – 2016-04-25T15:50:47.067

@OlivierDulac 2^64-1 is fine now. – Erik the Outgolfer – 2016-04-26T08:17:48.970

1zsh's maximum is 2^63 - 1 – joeytwiddle – 2016-04-26T14:49:57.667

2

JavaScript (ES6), 84 80 bytes

x=>{for(n=[r=i=0];r!=x;)(n[i]=-~n[i++]%10)&&alert(r=[...n].reverse(i=0).join``)}

Input is a string. Outputs as alert. Change alert to console.log if you want to keep your sanity.

I tried a few different methods then went to the print to infinity question to see how the JS answer there did it and found that I was the one who answered it. *facepalm* This approach is actually shorter though, so it worked out fine.

user81655

Posted 2016-04-25T12:04:11.443

Reputation: 10 181

2

Hoon, 13 bytes

(cury gulf 1)

++gulf returns a list containing the numbers from a to b. Returned a curried function with 1 for a.

Usage:

> %.  9
  (cury gulf 1)
~[1 2 3 4 5 6 7 8 9]

RenderSettings

Posted 2016-04-25T12:04:11.443

Reputation: 620

1I read this as "curry golf" :P – Downgoat – 2016-04-27T21:57:45.657

2

JavaScript (ES6), 99 103

String increment using regexp, not limit except the string length
Edit 1 byte saved thx @user81655

x=>{for(a='';a!=x;console.log(a=(' '+a).replace(/.9*$/,x=>++x[0]+'0'.repeat(x.length-1)).trim()));}

Test

f=x=>{for(a='';a!=x;console.log(a=(' '+a).replace(/.9*$/,x=>++x[0]+'0'.repeat(x.length-1)).trim()));}

console.log=x=>o.push(x)

function test() {
  var v = I.value
  o=[]
  if (/^\d+$/.test(v)) f(v)
  else console.log('Invalid number' + v)
  if(o.length > 30) o.splice(15,o.length-30,'','...','');
  O.textContent=o.join`\n`
}

test()
<input id=I value=10000><button onclick='test()'>go</button>
(this test snippet will show just the first and last 15 lines of the output)
<pre id=O></pre>

edc65

Posted 2016-04-25T12:04:11.443

Reputation: 31 086

Interesting approach. I think you can use a='' at the start because the added space works as a 0 anyway. – user81655 – 2016-04-26T14:46:08.910

I think you can omit the last semicolon. – Erik the Outgolfer – 2016-06-18T09:25:51.353

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ you can't, a for statement needs a body – edc65 – 2016-06-18T09:54:33.723

@edc65 Like when the last statement does not need the semicolon... – Erik the Outgolfer – 2016-06-18T09:55:49.070

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ ??? (anyway, try it, it won't work) – edc65 – 2016-06-18T10:01:44.710

2

C++14, 142 bytes

#include<numeric>
#include<list>
using namespace std;[](auto n)->list<decltype(n)>{list<decltype(n)>t(n);iota(t.begin(),t.end(),1);return t;};

This declares an anonymous lambda function which can be captured and subsequently called. The function returns a std::list containing values of the same type as n. The unsigned long long data type can be used on 64-bit machines to support the full 64-bit unsigned integer range (calling it like f(18446744073709551615ULL)).

Try it online

Mego

Posted 2016-04-25T12:04:11.443

Reputation: 32 998

I think this is only valid in C++14, not C++11 – anatolyg – 2016-04-27T14:51:21.350

@anatolyg std::iota, std::decltype, long long and lambda functions were all added in C++11.

– Mego – 2016-04-27T18:34:28.983

I mean, a lambda function with auto-typed argument. Isn't it new in C++14? – anatolyg – 2016-04-27T19:05:35.330

@anatolyg Oh, you're right, I forgot that generic lambdas weren't added until C++14. Fixing it now, thanks! – Mego – 2016-04-27T19:06:47.020

Do you need newline after std;? – Erik the Outgolfer – 2016-04-29T17:43:49.267

@ΈρικΚωνσταντόπουλος No, I don't. Good catch! – Mego – 2016-04-29T18:48:55.217

Can you use a macro? – Zacharý – 2016-11-15T22:00:15.343

2

Dyalog APL, 1 byte

This has worked since the very first APL, back in the seventies:

⍳⎕

No built-in (also always worked):

+\⎕⍴1

Cumulative sum +\ of input number of 1s.

Obviously you will need enough memory to contain the result. Here is a print loop to avoid memory full:

{⎕←1+⍵}⍣⎕⊢0

{return and print ⎕← 1+ argument } applied input times to 0.

Adám

Posted 2016-04-25T12:04:11.443

Reputation: 37 779

2

k/kona, 3 Bytes

1+!

e.g.

k)1+!15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Simon Major

Posted 2016-04-25T12:04:11.443

Reputation: 401

Please seprate this answer. We don't want [tag:polyglot]s in this challenge. – Erik the Outgolfer – 2016-06-07T16:40:06.607

@Erik Kona is an open-source implementation of the proprietary k language - they're equivalent rather than separate – Simon Major – 2016-06-08T09:20:12.447

Doesn't "Kona" have less abilities than "K" then? – Erik the Outgolfer – 2016-06-08T09:47:03.533

Presently, yeah, but it's aiming to be a full implementation of k. At which point it's the same thing as with Cython, Jython or IronPython - it's all a matter of semantics. – Simon Major – 2016-06-08T19:27:41.557

I prefer to be notified (and no, @Erik is not a notification, use @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ instead), not the last commenter. @SimonMajor – Erik the Outgolfer – 2016-06-09T06:41:20.760

2

PowerShell, 32 26 bytes

After reading the question thoroughly, I realized that my original answer does not support up to 2^64-1 since the range operator (..) in PS only supports 32bit integers.

Corrected answer:

for($x=0;$x-le$args[0];$x++){$x}

while($x++-ne$args[0]){$x}

Usage (save as count.ps1):

PS>count.ps1 8
1
2
3
4
5
6
7
8

Old method, supports only up to 2^32-1 taking input from the pipeline:

%{1..$_}

Since expressions are only allowed as the first element in the PowerShell pipeline, I have to wrap it in a foreach (%).

ThePoShWolf

Posted 2016-04-25T12:04:11.443

Reputation: 171

2

Sesos (non-competing), 3 bytes

Hexdump of generated binary file:

0000000: 16f8ce                                            ...

Size   : 3 byte(s)

Try it online!

Assembler:

set numin
set numout
get
jmp
sub 1
fwd 1
add 1
put
rwd 1
           ;implicit jnz

Brainfuck pseudocode: ,[->+.<]

Leaky Nun

Posted 2016-04-25T12:04:11.443

Reputation: 45 011

2

JAISBaL, 15 bytes

c1I0¯K0DQc1+I0´

Verbose:

# \# enable verbose parsing #\
pushnum 1        \# push 1 onto the stack #\
store 0          \# store the top value of the stack into var0 #\
for              \# start for loop #\
    load 0       \# push the value in var0 onto the stack #\
    duplicate    \# duplicate the top value of the stack #\
    popoutln     \# pop the top value off a stack and print it with a new line #\
    pushnum 1    \# push 1 onto the stack #\
    add          \# add the top two values of the stack #\
    store 0      \# store the top value of the stack into var0 #\
end              \# end current language construct #\

JAISBaL Noncompeting Answers These answers are noncompeting because they use the "range" instruction, which I added because of this challenge. I did not add them specifically to complete this challenge, rather this challenge brought the need for a range instruction to my attention.

Manual output, 4 bytes: (Manual output because the output at the end of a JAISBaL program can be considered debug information, although it is always enabled)

c1ØP

Verbose:

# \# enable verbose parsing #\
pushnum 1    \# push 1 onto the stack #\
rangein      \# push an array containing all numbers in the range of the two numbers on the top of the stack, inclusivley #\
popout       \# pop the top value of a stack and print it #\

Implicit Output, 3 bytes:

c1Ø

Same concept as the manual output answer, just without the print instruction.


Instruction codes and testing compatible with JAISBaL-0.0.6

Socratic Phoenix

Posted 2016-04-25T12:04:11.443

Reputation: 1 629

+1 for interest. Remember to +1 on challenges that you're interested in, and fav the most challenging ones. – Erik the Outgolfer – 2016-07-25T05:17:12.920

2

PHP, 26 bytes -20% = 20.8

<?=join(_,range(1,$argn));

run as pipe with -F.

or

while($i<$argn)echo++$i,_;

prints one trailing delimiter; run as pipe with -nR.

Titus

Posted 2016-04-25T12:04:11.443

Reputation: 13 814

2

Excel VBA, 48 47 46 22 21 Bytes

Immediates Window Function

Anonymous VBE Immediates Windows Function that takes input of the expected type Variant\Integer and from cell [A1] outputs to the VBE immediates window

For I=1To[A1]:?I:Next

Old Subroutine Version

Code:

Sub F(N):For I=1To N:Cells(I, 1)=I:Next:End Sub

Usage:

Sub Test(): F 100: End Sub

Changes:

-24 Bytes for converting to Immediates Window Function

-1 Byte for condensing I=1 To to I=1To

-1 Byte thanks to Engineer Toast for Changing Cells(I,1) to Debug.?

-1 Byte for removing whitespace


Output to ActiveSheet, 30 28 Bytes

Anonymous VBE immediate window function that takes input from range [A1] and outputs to the range [1:1]

[A1].Resize([A1],1)="=Row()"

-2 Bytes for removing A1 from Row(A1)

Taylor Scott

Posted 2016-04-25T12:04:11.443

Reputation: 6 709

1You can save 5 bytes by switching from Cells(I, 1)=I to Debug.?I – Engineer Toast – 2017-03-29T19:10:35.993

1Also, this only works up to a certain point before VBA cuts off the significant digits. After that, iterating by 1 won't work because it'll truncate it and return the same value. – Engineer Toast – 2017-03-29T19:32:09.313

@EngineerToast I have corrected this, thanks for pointing it out :) – Taylor Scott – 2017-03-30T02:57:00.813

1

LibreLogo, 35 bytes

Code:

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

Input:

enter image description here

Output:

enter image description here

Grant Miller

Posted 2016-04-25T12:04:11.443

Reputation: 706

1

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.

Engineer Toast

Posted 2016-04-25T12:04:11.443

Reputation: 5 769

1

Stax, 1 byte

m

Run and debug online!

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

Weijun Zhou

Posted 2016-04-25T12:04:11.443

Reputation: 3 396

1

Jelly, 1 byte

R

Try it online!

Leaky Nun

Posted 2016-04-25T12:04:11.443

Reputation: 45 011

1

Perl 5, 15 bytes + 8

Works with the -l and -Mbigint switch, and should work up to 2^64 with BigInt. Thanks to @andlrc for the 7 bytes shaved off.

print for 1..<>

Paul Picard

Posted 2016-04-25T12:04:11.443

Reputation: 863

You should use BigInt then. – Erik the Outgolfer – 2016-04-25T13:45:13.243

But you can do arbitary precision, thus you can count to pretty much infinite (2^65536 at least) – Bálint – 2016-04-25T14:52:06.353

1You can use print for 1..<> – andlrc – 2016-04-25T15:33:39.933

@andlrc Thanks ! – Paul Picard – 2016-04-26T06:49:42.987

@ΈρικΚωνσταντόπουλος Edited to match this. – Paul Picard – 2016-04-26T06:49:55.237

@Bálint How so? I'm not aware of this in Perl... Did a bit of research on the Perl documentation, but I haven't found anything I guess... :( – Paul Picard – 2016-04-26T06:51:07.463

@Paul Picard arbitary precision – Bálint – 2016-04-26T07:52:58.560

@PaulPicard I'm afraid this is +8 bytes, not +2... – Erik the Outgolfer – 2016-04-26T10:42:32.837

@ΈρικΚωνσταντόπουλος Ah, I thought each additional switch added only 1 byte. I should read the meta more... Fixed. – Paul Picard – 2016-04-26T12:43:55.753

@Bálint Use @PaulPicard instead. – Erik the Outgolfer – 2016-04-26T18:11:59.300

1

Go, 90 bytes

Naive solution:

package main
import ."fmt"
func main(){var n,b uint64
Scan(&n)
for;b<n;b++{Println(b+1)}}

Kristoffer Sall-Storgaard

Posted 2016-04-25T12:04:11.443

Reputation: 489

Can this count up to 2^64? – Distjubo – 2016-04-25T14:50:30.800

@Distjubo Only to 2^32-1 if I'm not horribly mistaken. Ought to be unsigned. – seequ – 2016-04-25T20:27:16.887

@Distjubo It's okay though (2^64-1, I've changed the limit 'cause standard loopholes) – Erik the Outgolfer – 2016-04-26T08:12:28.817

@Distjubo changed it to uint so I can get to 2^64-1 – Kristoffer Sall-Storgaard – 2016-04-26T08:16:23.507

Btw a signed 64-bit int has a max value of 2^63-1 and not 2^32-1 – Distjubo – 2016-04-26T12:18:10.213

1

Julia, 11 bytes

n->[1:n...]

This is an anonymous function that accepts an integer and returns an array from 1 to the input. This can handle large inputs just fine, it just requires passing n as a larger type, e.g. Int128 or BigInt.

Alex A.

Posted 2016-04-25T12:04:11.443

Reputation: 23 761

You may be able to implement support for large integers without providing a different type (although there is no such thing in the rules, it's still a creative idea). – Erik the Outgolfer – 2016-04-29T17:34:56.283

1

PHP, 32 bytes

for(;$i!=$argv[1];)echo++$i." "; 

57 Bytes

$c=function($e){$i=0;while($i!=$e)echo ++$i." ";};$c(10);

Martin Barker

Posted 2016-04-25T12:04:11.443

Reputation: 413

i just wish some would make a CG version of php just change reserved words into letters E.G function = func,while = w for = f foreach = fe – Martin Barker – 2016-04-25T14:30:14.187

I want it starting at 1. – Erik the Outgolfer – 2016-04-25T16:06:13.853

1You can trim your solution down to 32 bytes: for(;$i!=$argv[1];)echo++$i." ";. – insertusernamehere – 2016-04-25T21:55:56.290

@insertusernamehere If your language does not have any way to support huge integers up to 2^64, the upper limit of that particular language must be supported instead – Martin Barker – 2016-04-26T01:05:27.220

1If you increment inside the for, then you can spare 1 character by replacing string concatenation with variable embedding. I think another character can be spared by replacing != with < (though not sure, not read the entire requirement). for(;$i++<$argv[1];)echo"$i "; – manatwork – 2016-04-26T07:22:43.583

1

AutoHotKey, 58 bytes

Golfed and ungolfed are the same.

Golfed:

Ungolfed:

c:=0
x:=0
InputBox, x
while c<x{
    c:=c+1
    tooltip %c%
}

Michelfrancis Bustillos

Posted 2016-04-25T12:04:11.443

Reputation: 695

1Are you sure you need:=0 and not just =0 – downrep_nation – 2016-04-26T06:49:37.483

@downrep_nation Yes – Michelfrancis Bustillos – 2016-04-27T13:36:35.930

1

J, 4 bytes

>:i.

Try it online!

Leaky Nun

Posted 2016-04-25T12:04:11.443

Reputation: 45 011

1(sorry fo the late comment) but don't you need some form of x:? – Conor O'Brien – 2016-06-06T19:09:48.233

1

Bash, 17 bytes

eval echo {1..$1}

andlrc

Posted 2016-04-25T12:04:11.443

Reputation: 1 613

2I'm not sure you can count up to 2^64 (or even quite a bit less) ? – Olivier Dulac – 2016-04-25T15:50:31.503

1Isn't this limited by the maximum length of command line which is unlikely to gain 2^64 times average length of numbers? – rexkogitans – 2016-04-26T20:58:34.173

1

@rexkogitans The ARG_MAX constant is a kernel limit for the exec() system call, but echo is a Bash built-in, so no exec() is involved, and thus you can build the argument list to fill up available memory if you like. Unfortunately, this solution does precisely that. But given enough time and memory, it works up to the maximum number allowed in arithmetic expressions, which seems to be only 2^32-1 on OSX Yosemite (Bash 3.2) but should work up to the specified limit with newer versions.

– tripleee – 2016-04-27T04:53:05.160

@tripleee, yes it was exactly ARG_MAX I was thinking of, but this solution only expands the string twice. So, no reason for ARG_MAX. However, it loads the entire output into memory first (could become a problem with higher values). – rexkogitans – 2016-04-27T06:38:09.137

eval "echo -e \"\n\"{1..$1}" to separate numbers with a newline. – Yeti – 2016-05-21T22:12:42.577

Memory is not a problem with for((i=1;i<=$1;i++)){ echo $i; }, 32 Bytes Can someone write it shorter (without seq)? edit: for((;i<$1;)){ echo $[++i]; }, 29 Bytes, if we assume running an own shell. – rexkogitans – 2016-06-06T08:03:57.473

1

J - 27 bytes

9!:37[0 _ _ _
(,~<:@{.)^:<:

Usage

   (,~<:@{.)^:<: 20x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Explanation

This avoids using the built-in i. to generate a range.

First, J will truncate output if it's too long, so we disable that by setting the values to infinity _

9!:37[0 _ _ _

Second, the input has to be given as an extended integer, which can be done by marking it with a suffix of x.

The actual function is only 13 bytes, the change in settings another 13 bytes, and the newline between them is a byte, so 13 + 1 + 13 = 27.

(,~<:@{.)^:<:
           <:    - Decrement the input
         ^:      - Repeat the given verb that many times, nesting its calls
      {.         - Take the head of the input
   <:            - Decrement it
 ,~              - Prepend it to the input

miles

Posted 2016-04-25T12:04:11.443

Reputation: 15 654

1

AutoHotKey

I wasn't the first to post an answer in AHK, but mine are shorter for now. AutoHotKey doesn't like golf so the golfed versions are the same as the ungolfed versions. As for AutoHotKey's integer support:

For integers, 64-bit signed values are supported, which range from -9223372036854775808 (-0x8000000000000000) to 9223372036854775807 (0x7FFFFFFFFFFFFFFF). Any integer constants outside this range are not supported and might yield inconsistent results. By contrast, arithmetic operations on integers wrap around upon overflow (e.g. 0x7FFFFFFFFFFFFFFF + 1 = -0x8000000000000000).

Really Annoying Version - 25 bytes

Prints each number in a message box (super annoying) and takes input as the first argument on the command line.

i=1
Loop %1%
MsgBox % i++

i=1 - Loop counter set at 1
Loop %1% - Loop as many times as specified on the CLI
MsgBox % i++ = Display a message box with the digit in it, then increment

Alternate, Less Annoying Version - 43 bytes

This version displays only one message box but is much longer.

i=1
j=
Loop %1%
j:=j . i++ . " "
MsgBox %j%

i=1 - Loop counter set at 1
j= - Variable j set to an empty string
Loop %1% - Loop as many times as specified on the CLI
j:=j . i++ . " " - concatenate i and a space to j, then increment i
MsgBox %j% = Display a message box with j in it

Nakaan

Posted 2016-04-25T12:04:11.443

Reputation: 141

I hope there's a way to escape the loop! Counting just to 30 would be incredibly annoying. – Stewie Griffin – 2016-04-26T06:14:07.257

@StewieGriffin I mean, you can kill the process... But otherwise, no. – Nakaan – 2016-04-26T11:46:15.477

I think in the maximum signed int64 value you have 2 extra Fs. – Erik the Outgolfer – 2016-05-02T12:45:47.183

Here's a 26 byte less annoying version using Send as the output method (using \n to indicate a new line in the program because I need to use the accent/backtick in the program that messes with SE): Loop,%1%{ \n i++ \n Send,` %i% \n } – Engineer Toast – 2017-03-28T12:45:17.547

1

Befunge, 21 bytes

&>:  v
@^-1:_>,#a:#._

Counts down on the stack, then counts up. Compliance to the 2^64 rule may depend on implementation.

MegaTom

Posted 2016-04-25T12:04:11.443

Reputation: 3 787

Rule is 2^64-1 because I was forced to deny standard loopholes. – Erik the Outgolfer – 2016-04-26T08:20:58.767

1

PHP, 26 23 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

Martijn

Posted 2016-04-25T12:04:11.443

Reputation: 713

1

Hardcoding inputs is not allowed by default, and the author does not override that default (as you can see from this comment).

– Mego – 2016-04-26T09:33:49.380

Updated accordingly – Martijn – 2016-04-26T09:55:35.370

@Mego You are correct, I clearly state you must get n. I didn't do any override. – Erik the Outgolfer – 2016-04-26T10:48:18.417

Which I interpretted as "I get N from a constant" ;) But, changed my answer to the proper interpretation – Martijn – 2016-04-26T12:30:08.223

Isn't the statement-ending semicolon required? Omitting it on an online PHP codepad gives Fatal error: syntax error, unexpected $end, expecting ',' or ';' – nickb – 2016-04-27T04:05:57.057

>

  • yup, you need the semicolon. (+1) 2) Output must be separated by any character (or pattern) not in 0123456789: Use the underscore or a letter to get rid of quotation marks. (-2) 3) Consider using PHP 4.1 for $n with register_globals. (-6)
  • < – Titus – 2016-07-26T01:37:04.170

    I've added the semicolon, and also the $n, but register globals isnt really acceptable according to most people here :) – Martijn – 2016-07-26T07:57:35.573

    1

    Perl 6, 5 bytes

    1..+*
    

    Sadly, 1..* is an infinite range, so I've got to cheat to make Perl 6 understand it's actually an anonymous function (and * is the placeholder).

    Ven

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 382

    1

    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

    Conor O'Brien

    Posted 2016-04-25T12:04:11.443

    Reputation: 36 228

    What encoding is this? – Erik the Outgolfer – 2016-04-26T18:16:37.460

    You should add 1 byte because I must choose pretty output on. – Erik the Outgolfer – 2016-04-26T18:17:03.603

    @ΈρικΚωνσταντόπουλος 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 – 2016-04-26T18:22:10.037

    That's right. 2 more to go... – Erik the Outgolfer – 2016-04-26T18:41:34.163

    I don't think the encoding has to do something with here, as my name uses Unicode I think. – Erik the Outgolfer – 2016-04-29T17:40:47.017

    @ΈρικΚωνσταντόπουλος True, the internet is Unicode iirc, but I mean that your name (if I checked all the chars correctly) can be losslessly encoded in ISO-8859-7 (i.e. all the greek chars appear in the greek encoding.) – Conor O'Brien – 2016-04-29T18:38:38.653

    Oh yes. 8 more to go... – Erik the Outgolfer – 2016-04-29T18:39:51.910

    1

    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))
    

    Leaky Nun

    Posted 2016-04-25T12:04:11.443

    Reputation: 45 011

    1

    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
                   1                           # We start with 1
                         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
    

    Erik the Outgolfer

    Posted 2016-04-25T12:04:11.443

    Reputation: 38 134

    This won't work for all 64-bit integers, so it is invalid by your own rules. – Dennis – 2016-04-26T18:07:26.233

    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 – 2016-04-26T18:38:09.957

    You can use xrange(). Note: even xrange() may have issues, at least in 2.7.10. – user48538 – 2016-04-26T19:06:03.697

    I used it in my (sadly, shorter) Python 2 answer.

    – user48538 – 2016-04-26T19:07:43.040

    @zyabin101 I read it before posting, and I didn't want to copy you, 'cause that would be boring. Oh, and this was intended to be Python 3. – Erik the Outgolfer – 2016-04-27T08:38:22.503

    @Dennis I made a mistake on the title. It should now read Python 3. I actually wanted to write in Python 2 but discovered that Python 3 is shorter. – Erik the Outgolfer – 2016-04-27T08:42:57.730

    In Python 2 this would have been for n in xrange(1,int(raw_input())+1):print n with a trailing newline. (43 bytes) – Erik the Outgolfer – 2016-04-27T13:21:16.717

    @Dennis Edited my answer to hopefully be able to count up until 2**64-1! – Erik the Outgolfer – 2016-05-02T12:47:26.413

    1@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 – 2016-06-15T17:45:52.450

    @george The newer one supports 2^64-1. I was sleepy writing the newer one. – Erik the Outgolfer – 2016-06-16T07:57:28.583

    @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ ah that makes sense but you can still golf your new one – george – 2016-06-16T07:58:53.987

    @george Removed the older one because it was longer by now. – Erik the Outgolfer – 2016-06-16T08:26:11.783

    @george while i<int(input()) executes input() once every time the condition is checked. This will print 1, then exit with an EOFError. – Dennis – 2016-06-19T15:43:37.907

    @Dennis doh of course it does, I should have realised that – george – 2016-06-19T15:47:20.077

    1

    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

    tucuxi

    Posted 2016-04-25T12:04:11.443

    Reputation: 583

    Actually, I get exactly the same character count with cstdio as with iostream. Also, C++ doesn't require return 0. – anatolyg – 2016-04-27T14:46:37.167

    Thanks for the tip regarding return; also adding an iostream version, as you are again right - same byte count. – tucuxi – 2016-04-27T16:23:34.833

    1

    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.

    tucuxi

    Posted 2016-04-25T12:04:11.443

    Reputation: 583

    I disagree. Not all compilers support missing #includes. So you should add 18 bytes. – Erik the Outgolfer – 2016-04-27T12:35:38.507

    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 – 2016-04-27T13:07:43.603

    You mean this comment?

    – Erik the Outgolfer – 2016-04-27T13:18:35.420

    Yes - and thanks to you, I now know how to link comments :-) – tucuxi – 2016-04-27T16:17:03.193

    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 – 2016-04-27T17:29:01.707

    1

    C#, 105 117 109 107 101 99 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

    auhmaan

    Posted 2016-04-25T12:04:11.443

    Reputation: 906

    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 – 2016-11-08T10:46:50.290

    @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 – 2016-11-09T14:41:06.437

    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 – 2016-11-09T14:57:13.017

    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 – 2016-11-09T15:14:40.980

    you know you could just print it to the screen – hstde – 2016-11-09T19:16:26.410

    1You are right. That's why I need to learn to read... – auhmaan – 2016-11-10T17:47:17.950

    1

    Oracle SQL 11.2, 44 bytes

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

    Jeto

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 601

    Nice to see an answer in SQL derivatives! – Erik the Outgolfer – 2016-04-27T15:01:25.790

    1

    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))
    

    user8397947

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 242

    1

    Brachylog, 7 bytes

    :1:efrw
    

    or alternatively

    :1:efr.
    

    Fatalize

    Posted 2016-04-25T12:04:11.443

    Reputation: 32 976

    1

    Turing Machine Simulator - 1366 Bytes (124 Lines)

    0 * * r 0
    0 _ , r 1
    1 _ 1 r ,
    , _ , l 2
    2 * * l 2
    2 , * l 3
    3 _ * r 4
    3 1 0 l 4
    3 2 1 l 4
    3 3 2 l 4
    3 4 3 l 4
    3 5 4 l 4
    3 6 5 l 4
    3 7 6 l 4
    3 8 7 l 4
    3 9 8 l 4
    3 0 9 l 3
    4 * * l 4
    4 _ * r 5
    5 0 _ r 5
    5 , * * n
    5 * * r 6
    6 * * r 6
    6 , * r 9
    9 * * r 9
    9 _ * l z
    z * * l m
    m * * l m
    m , * r 7
    7 * * r 7
    7 , * * x
    7 0 p r p
    7 1 q r q
    7 2 w r w
    7 3 e r e
    7 4 r r r
    7 5 t r t
    7 6 y r y
    7 7 u r u
    7 8 i r i
    7 9 o r o
    8 * * l 8
    8 , * l m
    p * * r p
    p . * r P
    p _ . r P
    P * * r P
    P _ 0 l 8
    q * * r q
    q . * r Q
    q _ . r Q
    Q * * r Q
    Q _ 1 l 8
    w * * r w
    w . * r W
    w _ . r W
    W * * r W
    W _ 2 l 8
    e * * r e
    e . * r E
    e _ . r E
    E * * r E
    E _ 3 l 8
    r * * r r
    r . * r R
    r _ . r R
    R * * r R
    R _ 4 l 8
    t * * r t
    t . * r T
    t _ . r T
    T * * r T
    T _ 5 l 8
    y * * r y
    y . * r Y
    y _ . r Y
    Y * * r Y
    Y _ 6 l 8
    u * * r u
    u . * r U
    u _ . r U
    U * * r U
    U _ 7 l 8
    i * * r i
    i . * r I
    i _ . r I
    I * * r I
    I _ 8 l 8
    o * * r o
    o . * r O
    o _ . r O
    O * * r O
    O _ 9 l 8
    x * * r x
    x _ , l b
    b . 1 l c
    b 0 1 l c
    b 1 2 l c
    b 2 3 l c 
    b 3 4 l c
    b 4 5 l c
    b 5 6 l c
    b 6 7 l c
    b 7 8 l c
    b 8 9 l c
    b 9 0 l b
    c * * l c
    c _ * r v
    v * * r v
    v , * * 2
    n * * r n
    n _ * r halt
    n , _ r n
    n . _ r n
    n p 0 r n
    n q 1 r n
    n w 2 r n
    n e 3 r n
    n r 4 r n
    n t 5 r n
    n y 6 r n
    n u 7 r n
    n i 8 r n
    n o 9 r n
    

    You can try it out here - link Just set the initial input to the upper limit.

    Supports arbitrarily large integers

    KoreanwGlasses

    Posted 2016-04-25T12:04:11.443

    Reputation: 888

    Where is the spec for this language? – Erik the Outgolfer – 2016-07-19T17:05:31.583

    @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ It should be a the bottom of the page in the link – KoreanwGlasses – 2016-07-19T17:06:51.033

    Not the syntax, the states, what they mean, etc. – Erik the Outgolfer – 2016-07-19T17:08:08.663

    @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Is this what you're looking for? https://en.wikipedia.org/wiki/Turing_machine#Informal_description

    – KoreanwGlasses – 2016-07-19T17:16:09.280

    No, i wouldn't have asked if it was there. I don't mean the syntax, or how the states work, I mean what the states are. – Erik the Outgolfer – 2016-07-19T18:09:22.697

    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 (?).

    steenbergh

    Posted 2016-04-25T12:04:11.443

    Reputation: 7 772

    1

    Python 3, 31 bytes

    print(*range(1,int(input())+1))
    

    Outputs the range of numbers space-separated. Uses * operator magic to explode the output of range into separate arguments to print, which separates its arguments with spaces by default.

    Copper

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 684

    1

    Dip, 1 - .2 = .8

    l
    

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

    Oliver Ni

    Posted 2016-04-25T12:04:11.443

    Reputation: 9 650

    Can you provide a link to a Dip interpreter? I can´t find any reference to that language on the web. – Titus – 2017-07-07T15:20:40.580

    It was my language but i deleted it – Oliver Ni – 2017-07-08T16:24:30.123

    1

    Labyrinth, 41 29 23 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.

    Robert Hickman

    Posted 2016-04-25T12:04:11.443

    Reputation: 661

    0

    ><> (Fish), 16 bytes

    Solution 1

    01+:{:?!;1-rnao!
    

    Try it here!

    Solution 2

    01+::{:{(?;rnao!
    

    Solution 3

    0\
    o>1+::{:{(?;rna
    

    Wow can't believe I don't see any ><> submissions, have 3! All the solutions are 16 bytes, just structured differently (the top one would be my "real" submission I guess). Simply place n on the stack and away you go!

    Basic Explanation

    0                push 0 to the stack
     1+              add 1
       :             copy the result
        {            shift stack left
         :           copy n
          ?!;        if n is 0, end
             1-      subtract 1 from n
               r     reverse the stack
                n    output a number
                 ao  output a newline
                   ! skip the next instruction (0)
    

    Long Explanation

    As I made these in reverse order, I'll explain them in reverse order (probably be easier to follow)... These programs are pretty simple, I invite you to check out what the instructions do here.

    Explanation 3

    0\
     >
    

    This simply places 0 onto the stack (let's call it x), then tells the fish to move downwards, then to the right. We now have [n, x] on the stack, we'll place _s before temporary versions of these variables.

    The fish immediately must swim over 1+:: which adds 1 to x and then duplicates it twice, giving us the stack of [n, __x, _x, x]. {:{ shifts the stack to the left, copies n (because it's now on the end of the stack), then shifts the stack left again giving us [_x, x, n, _n, __x].

    Now the fish must figure out (?;, which starts with (. ( pops _n and __x off the stack and checks to see if _n is less than __x, pushing 1 to the stack if so, and 0 otherwise. Then ?; pops that result off the stack, executing ; (end of program) if it found a 1, and skipping over ; otherwise. This will end up with a stack of [_x, x, n].

    If the fish continues forwards it will encounter rnao because of the wrap-around, this simply tells the fish to reverse the stack, putting _x at the front of the stack, then outputting it as a number with the instruction n. ao simply places a newline on the stack (character 10 or a), and then outputs it.

    That's it!

    Explanation 2

    This is pretty much the same as Explanation 3. It doesn't have the fish mirror/movement instructions because it's only one line. It can do this because the ! at the end of the line causes the fish to skip the 0 at the beginning during the wrap-around.

    Explanation 1

    This solution is slightly different. I was hoping to save some bytes (you can see I didn't).

    You can see it deviates pretty early with :{:, instead of copying x twice in the beginning I only do it once, then I only do one stack shift left instead of two.

    I also don't use (?; and instead use ?!;, this is because n is actually being decremented each loop instead of just being compared to x. The ! is because ? actually does the opposite of what we want compared to before, so we invert its behaviour by executing ! when n>0, skipping the ;. Then the fish swims over 1- which simply subtracts 1 from n, and the program carrys on the same as the others!

    redstarcoder

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 771

    0

    Ruby, 12 bytes

    Lambda. Splats a range and prints that. Try it online!

    ->n{p *1..n}
    

    EDIT: I can't personally confirm that this counts up to 2^64-1, since it runs out of memory, but I believe Ruby uses bigints. If someone can confirm this, the score with bonus is 9.6.

    snail_

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 982

    0

    Silicon, 3 bytes

    1I\
    

    1 pushes... well, 1.

    I gets input and converts it to an integer before pushing it onto the stack.

    \ takes the two top stack items and runs it through the Python range() function.

    Output is implicit.

    m654

    Posted 2016-04-25T12:04:11.443

    Reputation: 765

    0

    Java, 163 (163 - 20% = 130.4, not sure if applies for bonus) bytes

    enum h{;public static void main(String[]a){long i=1;while(Long.compareUnsigned(i,Long.parseUnsignedLong(a[0]))!=1)System.out.println(Long.toUnsignedString(i++));}}
    

    Uses Java 8 functions to use unsigned longs which can store numbers up to 2^64-1(according to this page). Number is taken from first number

    Ungolfed version with comments:

    enum h {
        ;
    
        public static void main(String[] a) {
            long i = 1;                                                         // Counter
            while (Long.compareUnsigned(i, Long.parseUnsignedLong(a[0])) != 1)  // While counter is smaller or equal to input
                System.out.println(Long.toUnsignedString(i++));                 // Show counter as unsigned long(to be in correct range)
        }
    }
    

    cookie

    Posted 2016-04-25T12:04:11.443

    Reputation: 271

    0

    REXX, 27 bytes

    arg #
    do i=1 to #
      say i
      end
    

    Maximum number is dependent on NUMERIC DIGITS setting.

    idrougge

    Posted 2016-04-25T12:04:11.443

    Reputation: 641

    0

    Sinclair ZX80 BASIC, 4/8K ROM, ~38 bytes (4K ROM) listing

    This was an edit of my initial entry, however there is a slight issue with it, which is explained below:

    1 LET S=1
    2 INPUT N
    3 PRINT S,;
    4 LET S=S+1
    5 IF S<N+1 THEN GO TO 3
    

    ZX80 output

    Whilst there is nothing wrong with the logic, when the ZX80's DFILE (or screen) is full, the program will halt and you will be returned to direct mode, which will show your program listing.

    In order to get around this, press T on the ZX80's 'keyboard' and, on the 4K ROM version at least, the command CONTINUE should appear. Press NEW LINE and the program will continue where you left off. You can only do this once you have returned to direct mode though.

    As you may know, a ZX80 with an 'old ROM' (original 4K ROM) will only handle 16-bit signed integers so the range is limited and I'm not going to win the bonus points. If you enter a number <1 then it will print 1 then exit.

    This will work in other variants of Sinclair and 8-bit BASIC. On the ZX Spectrum though, this can be done in just two lines, like:

    1 LET s=1: INPUT n
    2 PRINT s,;: LET s=s+1: IF s<=n THEN GO TO 2
    

    Using a FOR..NEXT loop will condense the program further to just one line.

    Fortunately, the Spectrum, like all other more sane 8-bit personal computers, allows <= and >= in your conditions. If the 4K ROM ZX80 allows this, I've not found out how to do it yet.

    Shaun Bebbers

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 814

    1The challenge is about counting from 1 to n, not from n to m, so you only have one input. Also, input prompts are unneeded. I think you can also remove CLS. – Erik the Outgolfer – 2017-03-29T15:24:48.073

    0

    Modified processing. 39-7.8 = 31.2 bytes

    var n=0;for(var I=0;I<n;i++){print(I);}
    

    Uses this version of processing. In practice it cannot do it all the way until the max number but it could in theory. Also a side note it did say input as any way I wanted and that input is replaced by n.

    Christopher

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 428

    Let us continue this discussion in chat.

    – Erik the Outgolfer – 2017-03-29T15:20:09.123

    0

    Newline NC 23 bytes

    g\n[\nd\nq\np\ni\n|\na\n0\ng\n]
    

    \nis a newline. Try it online Input is in the variable numbers, that is STDIN for newline.

    Christopher

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 428

    Why can't you just use multiple lines for newlines? – HyperNeutrino – 2017-05-30T03:30:14.683

    @HyperNeutrino uhhhh idk takes up way to much space to view i guess – Christopher – 2017-05-30T12:29:36.440

    Okay. This way looks a bit unclear but up to you. – HyperNeutrino – 2017-05-30T12:57:47.163

    @HyperNeutrino it is also how the current interpreter works – Christopher – 2017-05-30T13:02:56.360

    Ah. Okay. Makes sense. Thanks for clarifying. – HyperNeutrino – 2017-05-30T13:08:45.620

    0

    Japt, 1 byte

    Outputs an array of integers.

    õ
    

    Try it online

    Shaggy

    Posted 2016-04-25T12:04:11.443

    Reputation: 24 623

    0

    JavaScript (ES6), 32 bytes

    Outputs an array of integers

    n=>[...Array(n)].map((_,y)=>++y)
    

    Try It

    f=
    n=>[...Array(n)].map((_,y)=>++y)
    oninput=_=>o.innerText=f(+i.value)
    o.innerText=f(i.value=6)
    <input id=i min=1 type=number><p id=o>

    Shaggy

    Posted 2016-04-25T12:04:11.443

    Reputation: 24 623

    0

    Braingolf v0.7, 14 bytes

    UV# R&,{_v!@R}
    

    Explanation:

    UV# R&,{_v!@R}  Implicit input of n
    U               Replace stack with ascending range 1-n
     V#<space>      Create new stack, switch to it and push space character
        R&,         Return to main stack and reverse stack
           {.....}  Foreach/Map loop, runs for each item in stack
            _       Pop and output last item on stack
             v!@    Switch to next stack and print a space
                R   Return to main stack
    

    Skidsdev

    Posted 2016-04-25T12:04:11.443

    Reputation: 9 656

    0

    Rust, 35 bytes

    |n|for i in 0..n{print!("{} ",i+1)}
    

    An anonymous function that does the task described. It can be one byte shorter if an inclusive range was used, but that's currently unstable. It is able to count to 2^64-1 (provided you call it with an u64 as argument).

    CensoredUsername

    Posted 2016-04-25T12:04:11.443

    Reputation: 951

    0

    Whitespace, 50 * 0.8 = 40 bytes (assumes n is on the stack)

       
    
      
       	
    	    
     	
     	   
    	
       
      	  	 
    	  	
    		
    
    

    Try it online!

    This code assumes n is already on the stack as it saves bytes over taking it from STDIN. The TIO link has a header provided to take n from STDIN so it can be tested more easily. An extra no-op command (stnn ; slide 0) has been added to the header to work around a TIO quirk where a newline gets introduced when the sections are concatenated.

    Whitespace numbers are arbitrary precision so this program exceeds the upper limit specified in the question. This uses a fixed number of stack elements so will not run into memory limits either.

    Explanation

    (s - space, t - tab, n - newline)

    ; The first four instructions are provided as a convenience to get input
    ;  from STDIN and leave it on the stack
    sssn  ; push 0
    sns   ; dup
    tntt  ; getnum - read number from stdin and save at address 0
    ttt   ; retrieve value from address 0 and place on the stack
    
    ; bytecount starts here
    sssn  ; push 0 - initialise i
    nssn  ; loop:
    ssstn ; push 1
    tsss  ; add - increment i
    sns   ; dup
    tnst  ; putnum - display i as a number
    sssn  ; push 0 - use null byte as a separator, shortest constant
    tnss  ; putchar - display null byte, often displayed as a space
    sns   ; dup - copy i
    stsstsn ; copy 2 - copy n
    tsst  ; sub - calculate i-n
    nttn  ; jlz "loop" - continue looping if i < n
    

    Ephphatha

    Posted 2016-04-25T12:04:11.443

    Reputation: 581

    0

    MY, 3 * 0.8 = 2.4 bytes

    Here's the hex:

    1A 49 27
    

    Explanation:

    1A - Take input as an integer, then push to stack
    49 - Pop n; Push [1 ... n]
    27 - Pop n; Output n (with a trailing newline)
    

    MY is written in Python, where integers have no size limit.

    Zacharý

    Posted 2016-04-25T12:04:11.443

    Reputation: 5 710

    0

    Swift 3, 53 bytes

    func c(n:UInt){var l:UInt=0;while l<n{l+=1;print(l)}}
    

    Note: this only works on 64-bit devices. Here is a 32-bit device solution (57 bytes):

    func c(n:UInt64){var l:UInt64=0;while l<n{l+=1;print(l)}}
    

    Herman L

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 611

    You only have to support natural upper limit. – Erik the Outgolfer – 2017-06-30T17:06:29.000

    0

    Swift 3, 40 bytes

    func f(n:UInt){for i in 1...n{print(i)}}
    

    Uses Swift ClosedRange (1...n) type. Prints up to UInt maximum aviable

    Sergii Martynenko Jr

    Posted 2016-04-25T12:04:11.443

    Reputation: 213

    0

    cQuents, 2.4 bytes (3 bytes - 20%)

    ::$
    

    Fairly simple, does exactly what the challenge wants. Since cQuents is implemented in Python, it works as long as Python integers can continue growing.

    Try it online!

    Explanation

          Implicit input n
    ::    Mode: Sequence 2. Output the sequence up to n
      $   Each item in the sequence is the current (1-based) index
    

    Stephen

    Posted 2016-04-25T12:04:11.443

    Reputation: 12 293

    Note current version uses & instead of :: (saves a byte) – Stephen – 2019-02-01T04:50:59.433

    0

    Retina, 18 bytes

    +`^1
    $%'$n1
    1+
    $.0
    

    Try it online!

    TwiNight

    Posted 2016-04-25T12:04:11.443

    Reputation: 4 187

    0

    Brainfuck, 24 bytes (-4.8 = 19.2)

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

    Technically it can go as high as you want as long as you set your cell size high enough.

    Also all I/O is in ascii.

    How it works is first it takes input into the third cell, then it duplicates itself (self-destructively) into the next two cells, and taking one away from the second one, repeating that unit it reaches 0. Then, it prints 1 and then goes back two spaces and prints until it reaches the beginning, where we skipped two spaces so it would terminate.

    vityavv

    Posted 2016-04-25T12:04:11.443

    Reputation: 734

    Does not seems to work... instead it prints the characters with the ascii from 1 to the ascii of the input character. – leo3065 – 2018-03-15T08:13:15.783

    1Also all I/O is in ascii – vityavv – 2018-03-15T10:57:37.727

    0

    Implicit, 10 5 bytes

    ¡(%ß;)
    

    Try it online!

    ¡(%ß;)   implicit integer input
    ¡        push 1..n
     (...)   while top of stack truthy
      %       print
       ß      print space
        ;     pop
    

    Old version:

    $(:-1);(%;)
    

    Input is implicit. When the first : is reached, there's nothing on the stack to duplicate so it reads an integer. This code is therefore equivalent to $(:-1);(%;). Explanation:

    $(:-1);(%;)
    $            read integer input
     (...)       do-while
      :           duplicate
       -1         decrement
          ;      pop the zero
           (..)  do-while
            %;   print and pop
    

    Take the input 3:

    $(:-1);(%;)
    $             read input (stack contains 3)
     (:-1)        push 2, 1, 0 (stack contains 3, 2, 1, 0)
          ;       pop zero
           (%;)   print 1, 2, 3
    

    Try it online! (Nonworking with (:-1);(%;) until TIO's SimpleStack interpreter is updated)

    MD XF

    Posted 2016-04-25T12:04:11.443

    Reputation: 11 605

    0

    Charcoal, 4 bytes

    I⊕…N
    

    Try it online!

    Explanation

    I     Cast (recursively vectorizes)
      ⊕    Incremented
       …N Range from 0 to next input as number (excluding the number itself)
    

    ASCII-only

    Posted 2016-04-25T12:04:11.443

    Reputation: 4 687

    0

    ABCR, 16 (-20%=12.8) bytes

    iBBaC.72Bc)qOC.x
    

    Output separated by null bytes.

    Explanation:

    i                   Read n to the register.
     BB                 Enqueue it to queue B twice.
       a                Since we need to count UP, we'll reset the register to 0.
        C               Save the current register value in queue C.
         .7             If not(the difference between the register (0) and n (from B)):
           2B           Clone n back to queue B, since calculating the difference
                            consumes the front of the queue
             c)q        Print the register value as a number, restoring its value 
                         from C and incrementing 
                O       Print out a null byte separator 
                           (the default value from queue A as a character)
    
                 C      Store it back in C
                  .x    If the difference between the register and n is 0, exit
    

    Steven H.

    Posted 2016-04-25T12:04:11.443

    Reputation: 2 841

    0

    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.

    RedClover

    Posted 2016-04-25T12:04:11.443

    Reputation: 719

    0

    hakr14

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 295

    0

    Tcl, 26 bytes

    time {puts [incr i]} $argv
    

    Try it online!

    First approach can't get more than 2^32-1 as it says integer value too large to represent as non-long integer if n is bigger.

    The limit can be even less, as I don't see output, but I am using an online compiler so I can not guarantee what happens on a local one.

    For 2123456789 there is output.


    Tcl, 32 bytes - 20% = 25.6 bytes

    while {[incr i]<$argv} {puts $i}
    

    Try it online!

    sergiol

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 055

    0

    Fortran (GFortran), 45 - 20% = 36 bytes

    INTEGER(16)I
    READ*,R
    DO1 I=1,R
    1 PRINT*,I
    END
    

    Try it online!

    The entire first line can be suppressed if the bonus is optional. In that case, the program will have only 32 bytes, i.e., the bonus is not worth of it! The default integer type in Fortran (which is implicitly assigned to variables whose names starts with I-N) uses only 4 bytes, then this lengthy declaration is necessary to handle such large numbers...

    Fortran (GFortran), 32 bytes

    READ*,R
    DO1 I=1,R
    1 PRINT*,I
    END
    

    Try it online!

    rafa11111

    Posted 2016-04-25T12:04:11.443

    Reputation: 310

    0

    F#, 36 bytes

    Try it online!

    let x n=for i=1 to n do printfn"%i"i
    

    Pretty straight-forward. This version does not count towards the bonus, because in F# you can only use int32 values for the for...to...do loops.

    For the bonus you can use this for 45 bytes:

    let r n=Seq.iter(fun x->printfn"%u"x)[1UL..n]
    

    Creates an array of n numbers, and prints each one out. The only thing is that it takes a lot of time and RAM. It's using about 20GB on my PC already, and it hasn't even printed a number yet. But hey, the code is small, right?

    Ciaran_McCarthy

    Posted 2016-04-25T12:04:11.443

    Reputation: 689

    0

    Gol><>, 6 - 1.2 (20%) = 4.8 bytes

    IFPD|;
    

    Try it online!

    The output looks like this:

    [1]
    [2]
    [3]
    ...
    [n]
    
    

    How it works

    IFPD|;
    
    I       Take input as int
     F  |   Pop n and repeat n times...
      PD    Increment top and print stack content as `[x]`
            Uses implicit zero on first iteration
         ;  Halt
    

    Bubbler

    Posted 2016-04-25T12:04:11.443

    Reputation: 16 616

    0

    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

    Dorian

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 521

    0

    Wren, 15 bytes - 3 = 12 bytes

    This is the exact same result before an interation of the thing.

    Fn.new{|n|1..n}
    

    Try it online!

    Wren, 24 bytes - 4.8B = 19.2 bytes

    Wren supports large integers by default, so... can I have the bonus?

    (Technically a returned operand of a function is a kind of output. Also the challenge didn't explicitly say that it has to be in Standard Output.)

    Fn.new{|n|(1..n).toList}
    

    Try it online!

    Wren, 38 bytes

    If this has to be in Standard Output I could do this...

    Fn.new{|n|System.print((1..n).toList)}
    

    Try it online!

    user85052

    Posted 2016-04-25T12:04:11.443

    Reputation:

    0

    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";
        }
    }
    

    Michelfrancis Bustillos

    Posted 2016-04-25T12:04:11.443

    Reputation: 695

    No C++ expert, but I think that int must return something. – Erik the Outgolfer – 2016-04-25T16:49:18.470

    Actually, no. The 'return 0' is implied by almost all modern compilers. – Michelfrancis Bustillos – 2016-04-25T17:04:31.680

    does std::cin>>c work i though it would cause type cast error char* to int... – Martin Barker – 2016-04-26T01:11:45.093

    @MartinBarker That error only occurs if the user inputs something other than an int. – Michelfrancis Bustillos – 2016-04-26T03:13:12.270

    1You 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 – 2016-04-26T07:29:31.143

    Doh. A lameness in my yesterday comment. x can be initialized in the declaration instead of for to spare another character: int c,x=1. – manatwork – 2016-04-27T07:37:19.830

    Doh. Another one. Counting from 0 to <c with pre-increment is shorter. int main(){int c,x=0;std::cin>>c;for(;x<c;)std::cout<<++x<<"\n";} – manatwork – 2016-04-27T07:45:03.927

    int is not 64 bits on most platforms - you should probably use long instead – tucuxi – 2016-04-27T12:04:42.187

    you can save 6 chars by replacing main(){int c;std::cin>>c;for(int x=1 by main(x){int c;std::cin>>c;for( - x will be an int initialized to 1 for free. Still, it will be 32-bit, (see my other comment), so you cannot count up to the full (2<<64)-1 – tucuxi – 2016-04-27T13:11:58.350

    0

    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

    Timtech

    Posted 2016-04-25T12:04:11.443

    Reputation: 12 038

    Could you support 2^64-1 with seq(I,I,1,Ans? – Erik the Outgolfer – 2016-04-26T08:17:09.013

    @ΈρικΚωνσταντόπουλος 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 – 2016-04-26T18:41:43.193

    Then keep your 11-keystroke solution. – Erik the Outgolfer – 2016-04-26T18:42:38.780

    0

    GameMaker Language, 38 bytes

    for(i=0;i<argument0;show_message(++i))
    

    Timtech

    Posted 2016-04-25T12:04:11.443

    Reputation: 12 038

    Couldn't you do for(i=0;i<argument0;show_message(++i)) for -3 bytes? – Erik the Outgolfer – 2016-06-18T09:39:51.227

    I suppose, thanks for the tip. – Timtech – 2016-06-18T21:00:07.447

    0

    Bash, 34 Bytes

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

    Split answer from GNU coreutils, this is pure bash.

    rexkogitans

    Posted 2016-04-25T12:04:11.443

    Reputation: 589

    3for((;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 – 2016-04-25T17:54:44.167

    That's the limit for 32 bit integers, not 64. – CalculatorFeline – 2016-04-26T05:31:10.873

    @DigitalTrauma 64-bit integers meet the spec (2^64-1), 32-bit ints don't. It's fine, though. – Erik the Outgolfer – 2016-04-26T08:19:11.193

    1The sign uses one of the 64 bits (not half of them!), so bash's maximum is 2^63-1 (empirically verified). – joeytwiddle – 2016-04-26T14:39:34.487

    @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 – 2016-04-26T14:57:25.493

    @DigitalTrauma Why not 2^64-1? – Erik the Outgolfer – 2016-04-26T18:10:16.667

    @ΈρικΚωνσταντόπουλος Because bash uses signed 64-bit integers (long long int) which run in the range -2^63 to 2^63-1, or -9223372036854775808 to 9223372036854775807. Bash arithmetic is unable to express anything larger than 2^63-1 without overflow - try it: echo $((2**63)) $((2**64)) $((2**64 - 1)). https://en.wikipedia.org/wiki/C_data_types

    – Digital Trauma – 2016-04-26T18:32:36.747

    Oh. 12 more to go... – Erik the Outgolfer – 2016-04-26T18:39:00.413

    @joeytwiddle I discovered after I typed that comment. – Erik the Outgolfer – 2016-04-27T13:14:16.367

    0

    Ruby, 18 12 bytes

    ->n{p *1..n}
    

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

    MegaTom

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 787

    Can't you remove that space? – Erik the Outgolfer – 2016-04-27T13:14:36.103

    @ΈρικΚωνσταντόπουλος No. if i do it will try to multiply. – MegaTom – 2016-04-27T15:10:34.210

    Oh 13 more to go... – Erik the Outgolfer – 2016-04-27T15:41:03.220

    You can use p instead of puts – daniero – 2016-04-29T11:56:01.763

    0

    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." "; 
    

    Martin Barker

    Posted 2016-04-25T12:04:11.443

    Reputation: 413

    Can't you remove the space? e ++ – Erik the Outgolfer – 2016-04-29T17:49:37.800

    Not yet, your welcome to code it it in and send me a pull request :) – Martin Barker – 2016-04-30T21:16:13.990

    1how about f(;$i++!=$argv[1];)e"$i ";? – Titus – 2016-07-26T01:38:36.903

    0

    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.
    

    user47018

    Posted 2016-04-25T12:04:11.443

    Reputation:

    0

    Scratch, 12 10 bytes

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

    weatherman115

    Posted 2016-04-25T12:04:11.443

    Reputation: 605

    Finally an answer! – Erik the Outgolfer – 2016-05-20T14:51:47.570

    Scratch projects are meant to run multiple times. – weatherman115 – 2016-05-20T15:24:57.347

    See my remix – Erik the Outgolfer – 2016-05-20T15:34:48.137

    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 – 2016-05-20T15:37:22.370

    scratchblocks – Erik the Outgolfer – 2016-05-21T13:14:57.640

    0

    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.

    m654

    Posted 2016-04-25T12:04:11.443

    Reputation: 765

    0

    Desmos, 60+table bytes

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

    Table
    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.

    weatherman115

    Posted 2016-04-25T12:04:11.443

    Reputation: 605

    I want the meta link. – Erik the Outgolfer – 2016-06-03T06:42:42.157

    Link – weatherman115 – 2016-06-03T21:50:58.147

    0

    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.

    m654

    Posted 2016-04-25T12:04:11.443

    Reputation: 765

    0

    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.

    Erik the Outgolfer

    Posted 2016-04-25T12:04:11.443

    Reputation: 38 134

    0

    PureData, 462 bytes

    As file:

    #N canvas 778 126 591 616 10;
    #X obj 136 137 until;
    #X obj 175 177 f;
    #X obj 258 160 + 1;
    #X obj 352 194 + 1;
    #X msg 215 126 0;
    #X obj 393 211 log/normal;
    #X obj 215 96 moses;
    #X obj 215 66 - 1;
    #X msg 136 49 1.84467e+019;
    #X connect 0 0 1 0;
    #X connect 1 0 2 0;
    #X connect 1 0 3 0;
    #X connect 2 0 1 1;
    #X connect 3 0 5 0;
    #X connect 3 0 6 1;
    #X connect 4 0 1 1;
    #X connect 6 0 4 0;
    #X connect 6 0 0 1;
    #X connect 7 0 6 0;
    #X connect 8 0 0 0;
    #X connect 8 0 7 0;
    

    Actual program, because it's a graphical programming language:

    enter image description here

    Note: Do NOT run it with this value as it will run for a very long time!

    Gábor Fekete

    Posted 2016-04-25T12:04:11.443

    Reputation: 2 809

    moses? 18446744073709551615? Did you really have to impose that limit explicitly? – Erik the Outgolfer – 2016-07-19T19:23:48.793

    moses will part the sea, in this case it works like an if statement, if the left inlet's value is less than the right inlet's value it will send a bang through it's left outlet. I couldn't find any standard input like object in it, so you have to write your input number into that message box and click on it so the program starts. – Gábor Fekete – 2016-07-19T19:28:27.727

    Is this a joke language? moses will part the sea? Sounds religious to me... – Erik the Outgolfer – 2016-07-19T19:34:29.970

    puredata or pd is a discontinued visual programming language mostly for processing and generating sound. moses distributes the input value through it's outputs. – Gábor Fekete – 2016-07-19T19:38:18.380

    0

    Emacs Lisp, 39 bytes

    (lambda(n)(princ(number-sequence 1 n)))
    

    Lord Yuuma

    Posted 2016-04-25T12:04:11.443

    Reputation: 587

    0

    Jellyfish, 5 bytes

    p`>ri
    

    Try it online!

    Explanation

    p     `    >         r     i
    print(each_increment(range(input)))
    

    Leaky Nun

    Posted 2016-04-25T12:04:11.443

    Reputation: 45 011

    0

    C#, 47 bytes

    l=>{for(int i=1;i<=l;)Console.WriteLine(i++);};
    

    TheLethalCoder

    Posted 2016-04-25T12:04:11.443

    Reputation: 6 930

    0

    Mouse-2002, 47 bytes

    ?1(&DUP " "!&DUP &ROT &DUP &ROT =[0^]&SWAP 1+)$
    

    I do not know how to replace &DUP &ROT &DUP &ROT ...&SWAP, it's intended to duplicate the two top elements of the stack (...A B → ...B A A B), perform an operation on them, and then restore the stack to what it was before (...A B). Here is the explanation:

    • ? pushes a number (base 10) from input (... → ... <input num>)
    • 1 pushes 1 (... → ... 1)
    • ( starts an infinite loop
    • &DUP duplicates the ToS (... A → ... A A)
    • " " prints
    • ! prints the ToS as a number (... A → ...)
    • &DUP duplicates the ToS (... A → ... A A)
    • &ROT rotates the top three stack elements (... A B C → ... B C A)
    • &DUP duplicates the ToS (... A → ... A A)
    • &ROT rotates the top three stack elements (... A B C → ... B C A)
    • = checks if the ToS and the SToS are equal
    • [ skips to the matching ] if the ToS is not positive
    • 0 pushes 0 (... → ... 0)
    • ^ breaks out of the innermost loop if the ToS isn't positive (... A → ...)
    • &SWAP swaps the top two stack elements (... A B → ... B A)
    • 1 pushes 1 (... → ... 1)
    • + adds the top two stack elements (... A B → ... A+B)
    • ) closes the innermost loop
    • $ terminates the program

    Erik the Outgolfer

    Posted 2016-04-25T12:04:11.443

    Reputation: 38 134

    0

    R, 35 bytes

    This statistician's language also has a scan() function, but requires information about how many characters it will receive, and providing a value for that would either limit the highest possible x, or require a very, very long argument.

    for(x in 1:readline()){cat(x,'\n')}

    James Murphy

    Posted 2016-04-25T12:04:11.443

    Reputation: 267

    0

    SQL, 108 Bytes

    Golfed:

    CREATE PROCEDURE C @n INT AS BEGIN DECLARE @a INT;SET @a=1;WHILE @a<=@n BEGIN PRINT @a;SET @a=@a+1;END;END
    GO
    

    (It fails if I put it all on one line!)

    Ungolfed:

    CREATE PROCEDURE C 
    @n INT
    AS
    BEGIN
    DECLARE @a INT;
    SET @a=1;
        WHILE @a<=@n 
            BEGIN 
            PRINT @a;
            SET @a=@a+1;
        END;
    END
    GO
    

    Usage:

    EXEC C 5
    

    Output:

    1
    2
    3
    4
    5
    

    Pete Arden

    Posted 2016-04-25T12:04:11.443

    Reputation: 1 151

    0

    C++, 89 83-20%=66.4 bytes

    #include<iostream>
    auto f=[](auto n){for(decltype(n)i=0;i++<n;)std::cout<<i<<",";};
    

    Should work for up to 2^64-1

    Karl Napf

    Posted 2016-04-25T12:04:11.443

    Reputation: 4 131

    0

    R, 3 bytes

    seq
    

    A built-in function that, when given a single positive integer n as argument, yields 1 to n.

    rturnbull

    Posted 2016-04-25T12:04:11.443

    Reputation: 3 689

    0

    PostL (Non-competing) 20 bytes

    I made this language after the challenge was posted; thus, this answer is non-competing. It's a postfix-notation stack-based language based purely on the stack, a single variable, and many operators, and its interpreter is currently written in Java.

    1N0,$)B>\`]`=>1+.6;>
    

    Explanation:

    1N0,$)B>\`]`=>1+.6;>
    1                    Push 1 onto the stack
     N                   Negate it (gives -1; negative literals don't exist)
      0                  Push 0 onto the stack
       ,$                Take the input and parse it to an number
         )               Take the range, counting by -1, to 0, starting at whatever the input was
          B>             Check whether or not the stack is empty, and push that onto the stack (0 for not, 1 for empty)
            \`           Push on a SKIP processor flag, and move the value of the emptiness of the stack back to the top (swap the top two)
              ]`         Push on a TERMINATE processor flag, and swap the top two.
                =        Switch, based on whether or not the stack is empty. If not, retrieve the SKIP flag, and if so, retrieve the TERMINATE flag.
                 >       Process whatever flag is there. If it's a SKIP flag, it doesn't do anything, but if it's a TERMINATE flag, it means that the stack is empty, and it terminates.
                  1+     Add 1 (because the range is 0 to n - 1)
                    .    Pop it off the stack and print it
                     6;> Go to index 6 (where the program checks if the stack is empty).
    

    HyperNeutrino

    Posted 2016-04-25T12:04:11.443

    Reputation: 26 575

    0

    D, 55 bytes

    (ulong n){import std.stdio;foreach(i;1..n+1)i.writeln;}
    

    Zacharý

    Posted 2016-04-25T12:04:11.443

    Reputation: 5 710

    -1

    Maple, 9 bytes

    seq(1..n)
    

    Usage:

    > seq(1..10);
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10
    

    DSkoog

    Posted 2016-04-25T12:04:11.443

    Reputation: 560

    -1

    Ruby 17Byte

    1.upto(n){|i|p i}
    

    بارپابابا

    Posted 2016-04-25T12:04:11.443

    Reputation: 159