| Bytes | Lang | Time | Link |
|---|---|---|---|
| 040 | ReRegex | 250112T225033Z | ATaco |
| 012 | Regenerate a | 250107T233518Z | Unrelate |
| 013 | COPY WITH @ | 241222T193116Z | Gleb |
| 008 | jive | 241227T174552Z | Gleb |
| nan | 160425T142256Z | Robert B | |
| 011 | Kakoune | 241222T170626Z | JoshM |
| 001 | Actually | 160426T052645Z | user4594 |
| 009 | Uiua | 240418T140805Z | Adelie |
| 009 | Rattle | 240206T040841Z | d01 |
| nan | 230531T124234Z | Dadsdy | |
| nan | Go | 230531T134029Z | bigyihsu |
| 008 | Desmoslang Assembly | 230529T143230Z | Dadsdy |
| nan | Python | 230529T131344Z | The Empt |
| 044 | Rockstar | 230529T085258Z | Shaggy |
| 001 | Thunno 2 | 230528T190439Z | The Thon |
| 006 | QBIC | 160722T212535Z | steenber |
| 003 | Sesos | 160722T210043Z | Leaky Nu |
| 031 | Oration | 160606T180159Z | Żáł |
| 005 | J | 220219T215223Z | sinvec |
| nan | Factor | 210919T022645Z | chunes |
| 020 | PostL | 161110T202852Z | hyperneu |
| 015 | Ly | 210601T095358Z | cnamejj |
| 008 | Vyxal | 210601T091936Z | emanresu |
| nan | Flurry | 200814T042443Z | Bubbler |
| 030 | MAWP 1.0 | 200808T155601Z | Razetime |
| 008 | Integral | 200806T100931Z | user9649 |
| nan | Wren | 191206T143642Z | user8505 |
| 014 | BrainFlak | 190917T111320Z | Dorian |
| 025 | Pepe | 180226T180006Z | RedClove |
| nan | Gol><> | 180415T064214Z | Bubbler |
| 036 | F# | 180412T220122Z | Ciaran_M |
| nan | Canvas | 180226T183855Z | hakr14 |
| nan | Fortran GFortran | 180315T033551Z | rafa1111 |
| 001 | Stax | 180315T022453Z | Weijun Z |
| 018 | Stack Cats with nl | 180313T015108Z | Bubbler |
| 026 | Tcl | 180226T191140Z | sergiol |
| 029 | MarioLANG | 160425T121609Z | Erik the |
| nan | ABCR | 171121T104857Z | Steven H |
| 005 | Implicit | 170907T034010Z | MD XF |
| 004 | Charcoal | 170907T061528Z | ASCII-on |
| nan | Brainfuck | 170904T203702Z | vityavv |
| 021 | Excel VBA | 161110T122401Z | Taylor R |
| 003 | k/kona | 160606T153800Z | Simon Ma |
| 018 | Retina | 170719T225603Z | TwiN |
| nan | cQuents | 170719T123815Z | Stephen |
| 040 | Swift 3 | 170707T173124Z | Sergii M |
| nan | PHP | 161102T174216Z | Titus |
| 053 | Swift 3 | 170630T170136Z | Endenite |
| 061 | TSQL | 170630T164009Z | BradC |
| nan | MY | 170630T151414Z | Adalynn |
| nan | Whitespace | 170604T092326Z | Ephphath |
| 035 | Rust | 170530T145947Z | Censored |
| 014 | Braingolf v0.7 | 170530T131137Z | Mayube |
| 032 | JavaScript ES6 | 170530T131035Z | Shaggy |
| 001 | Japt | 170530T130532Z | Shaggy |
| 023 | Newline NC | 170528T201010Z | user6318 |
| 384 | Sinclair ZX80 BASIC | 170328T124841Z | Shaun Be |
| nan | Modified processing. 397.8 = 31.2 bytes | 170328T151928Z | user6318 |
| 264 | Taxi | 170328T140317Z | Engineer |
| 027 | REXX | 170328T122630Z | idrougge |
| 010 | ><> | 170326T171931Z | Leo |
| nan | Java | 170326T115122Z | user6333 |
| 003 | Silicon | 170326T100654Z | m654 |
| 012 | Ruby | 170326T072546Z | snail_ |
| 035 | LibreLogo | 170326T065255Z | Grant Mi |
| 016 | ><> Fish | 161129T212225Z | redstarc |
| 014 | Labyrinth | 161102T173214Z | Robert H |
| 038 | GameMaker Language | 160425T145233Z | Timtech |
| 055 | D | 161115T233828Z | Adalynn |
| nan | 160427T132722Z | auhmaan | |
| 017 | Ruby 17Byte | 161110T131923Z | Baba |
| 003 | R | 161107T193218Z | rturnbul |
| nan | C++ | 161107T184438Z | Karl Nap |
| 108 | SQL | 161102T172246Z | Pete Ard |
| 128 | Dip | 161031T174315Z | Oliver N |
| 035 | R | 161101T012359Z | James Mu |
| 047 | Mouse2002 | 161031T172333Z | Erik the |
| 017 | Cubix | 160425T234443Z | MickyT |
| 047 | C# | 160805T155536Z | TheLetha |
| 005 | Jellyfish | 160805T092212Z | Leaky Nu |
| 031 | Python 3 | 160727T184151Z | Copper |
| 031 | PHP | 160426T091904Z | Martijn |
| 009 | Maple | 160725T170151Z | DSkoog |
| 015 | JAISBaL | 160724T230413Z | Socratic |
| 039 | Emacs Lisp | 160722T210622Z | Lord Yuu |
| 011 | UGL | 160426T151422Z | Leaky Nu |
| 462 | PureData | 160719T191400Z | Gáb |
| nan | Turing Machine Simulator 1366 Bytes 124 Lines | 160719T170101Z | KoreanwG |
| 026 | PowerShell | 160719T163803Z | ThePoShW |
| 042 | Python 3 | 160426T175223Z | Erik the |
| 036 | Python 2 | 160619T114127Z | Erik the |
| 058 | JavaScript ES6 | 160425T190025Z | Shaun H |
| 043 | QBASIC | 160428T115155Z | Michelfr |
| 007 | Brachylog | 160605T075132Z | Fatalize |
| 039 | Common Lisp | 160604T192152Z | user8397 |
| 006 | PyCal | 160604T191319Z | m654 |
| 060 | Desmos | 160602T195954Z | weatherm |
| 001 | Dyalog APL | 160428T124343Z | Adá |
| 132 | Javascript | 160425T122522Z | Bál |
| 006 | Tellurium | 160522T131630Z | m654 |
| 010 | Scratch | 160520T130108Z | weatherm |
| 006 | Joe 2 or | 160425T200746Z | seequ |
| 064 | Piet | 160502T192109Z | Marv |
| 012 | Ruby | 160425T200625Z | MegaTom |
| 142 | C++14 | 160426T093155Z | user4594 |
| 081 | C++ | 160427T121111Z | tucuxi |
| 044 | Oracle SQL 11.2 | 160427T145710Z | Jeto |
| 061 | C | 160427T121550Z | tucuxi |
| 415 | ArnoldC | 160427T101455Z | drolex |
| nan | Java 8 | 160425T211729Z | CAD97 |
| 007 | FuzzyOctoGuacamole | 160426T181738Z | Bald Ban |
| 015 | dc | 160425T204538Z | Digital |
| nan | Jolf | 160426T130351Z | Conor O& |
| 099 | JavaScript ES6 | 160426T090331Z | edc65 |
| nan | 160425T202854Z | Nakaan | |
| 158 | Perl 5 | 160425T134427Z | Sake |
| 019 | MarioLANG | 160425T135956Z | Martin E |
| 005 | Perl 6 | 160426T115257Z | Ven |
| 010 | Molecule | 160426T112432Z | user4701 |
| 090 | Go | 160425T135613Z | Kristoff |
| 006 | GNU Coreutils | 160425T150545Z | rexkogit |
| 011 | Julia | 160425T140505Z | Alex A. |
| 028 | PGP | 160426T015430Z | Martin B |
| 032 | PHP | 160425T141903Z | Martin B |
| 013 | Hoon | 160426T000635Z | RenderSe |
| 021 | Befunge | 160425T223151Z | MegaTom |
| 019 | Hexagony | 160425T211106Z | FryAmThe |
| 023 | GNU bc | 160425T203259Z | Digital |
| 027 | J | 160425T195437Z | miles |
| 010 | Haskell | 160425T185719Z | nimi |
| 034 | Bash | 160425T151516Z | rexkogit |
| 080 | JavaScript ES6 | 160425T153913Z | user8165 |
| 011 | V | 160425T134122Z | DJMcMayh |
| 012 | Zsh | 160425T153649Z | Andreas |
| 017 | Bash | 160425T153054Z | Andreas |
| 011 | TIBasic | 160425T144906Z | Timtech |
| 004 | J | 160425T150703Z | Leaky Nu |
| 058 | AutoHotKey | 160425T144312Z | Michelfr |
| 091 | C++ | 160425T143541Z | Michelfr |
| 001 | Pyke | 160425T124747Z | Blue |
| 005 | Mathematica | 160425T132103Z | A Simmon |
| 002 | Pyth | 160425T124635Z | Maltysen |
| 033 | Python 2 | 160425T121933Z | user4853 |
| 001 | Jelly | 160425T124429Z | Leaky Nu |
| 007 | MATLAB | 160425T122749Z | Stewie G |
| 001 | MATL | 160425T123336Z | Stewie G |
| 013 | R | 160425T123250Z | Masclins |
| 005 | Cjam | 160425T122455Z | Denker |
| 001 | 05AB1E | 160425T121905Z | Adnan |
| 001 | Pyth | 160425T121705Z | orlp |
ReRegex, 40 bytes
#import base
^(_*)_/$1,d<$1_>/u<#input
>
Whilst it theoretically can support the bonus, practically it can't as Java strings start getting messy ~2^32 in length.
Regenerate -a, 12 bytes
( {1,$~1})#1
With the -a flag to output every possible generation separated by newlines, this leans on the allowance for non-decimal pattern separators to create a diagonal staircase of spaces then output the length of each layer. I don't like bonuses regardless, but it still seems worth mentioning that it seems dubious that this could count up to \$2^{64}-1\$--even if the Python-based interpreter didn't hit the recursion limit, it would have to actually construct a string of spaces that long and hold it in memory (without hypothetical optimizations).
Regenerate, 17 bytes
( ${$1+1}!1){$~1}
Without the -a flag, this instead uses deterministic repetition to run a loop bounded by the input that increments the last value produced by that loop, starting with 1 and separating subsequent iterations with a single clean space (which luckily doesn't prevent successful integer parsing!). Still has the same memory issues with large inputs because the entire string representation of the range is held in memory all at once.
COPY WITH @, 13 bytes
?↷-↷{↷+↷-↷!↷}
jive, 8 bytes
*`,[↺(↓)
I have to implement the range command and the while loop command in jive online
AWK 18.4 25 23 bytes
Score includes 21 bytes of code, 2 bytes for option -M (added to support arbitrary precision) and -4.6 bonus.
{for(;j<$1;)print++j}
Note: The TIO link will halt after it fills its buffer, or after it runs for more than 60 seconds.
The following version shows how to count the last 10 integers that preceed the input to verify accuracy.
{for(j=$1-10;j<$1;)print++j}
Kakoune, 16, 11 bytes
ea+"#p<esc>"@dq
(assumes we start at the beginning of a buffer containing just the input number)
we append the keys we would want executed to the input and then cut everything to the default macro register then run the macro
e # select to end of input
a # enter insert mode appending keys to selection
+ # spawn <n> cursors (in macro)
"#p # paste cursor index (in macro)
<esc> # exit insert mode
"@d # cut everything to default macro register
q # run macro
Kakoune does in fact have a limit on the parameters passed to operators of 1 billion which is obviously less than 2^64-1 = 18446744073709551615. I also tested adding 1 billion cursors and it crashed although 100 million worked. Even if spawning 2^63-1 cursors didn't crash the program, pasting (2^64-1) x O(log(n)) bytes would take up way way way too much memory for this approach to work. but in principle it could work if modern computers had hundreds of exabytes of memory and the limit for operator parameters were raised.
if n were allowed to be inserted before the program we could do it in 5 bytes. I'm not sure but I think that counts as hardcoding, if it doesn't then let me know.
<n> is input
<n>+"#p
old:
x_d:exec <c-r>"+"#p<ret>
x_d # cut trimmed input
:exec # start a command that will execute keys
<c-r>" # insert input into command
+ # spawn that many cursors
"#p # paste cursor index
<ret> # submit command
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)
Uiua, 9 bytes SBCS
Surprised nobody's answered with this language yet. Full program that outputs as a space-separated array.
&p+1⇡⋕&sc
According to one of the error messages (and a bit of picking around), Uiua arrays are given a size limit of 33,554,432 elements.
Explanation
&p+1⇡⋕&sc
&sc # Read line of input
⋕ # Parse as number
⇡ # Make array of all positive integers less than n
+1 # Add 1 to every element
&p # Print to stdout with linefeed
Rattle, 9 bytes
|!s=[+p]~
Explanation
|! take input, disable implicit output
s save input to memory
= set top of stack to 0
[ ]~ loop n times, n is the vale in memory
+p increment and print
(,) 352 243 Chars or \$243\log_{256}(3)\approx48.14\$ Bytes
(()(),()()()()()()())(,(((),(())(),,,(()()())()(),(())(()(),,,,(),,(()())))((()()),((()()),,,,(),,(()())()()())((),(,,,,,())))((),(())(),,,((()())),(())())((()()),((),(,,,,,())))),,,(,(()()(),((()))))(()()()),())(,,()((),(())()),,(),,((()())))
If we can take input in unary, 27 Chars or \$27\log_{256}(3)\approx\$5.35 Bytes:
(,,((),(())())(),,((()())))
Go, 44 - 20% = 35.2 bytes
func(n uint64){for i:=0;i<n;i++{println(i)}}
Prints to STDERR, with each number on its own line.
Desmoslang Assembly, 8 Bytes
[1...IOT
Explanation: The ending bracket is automatically added, you can output lists, and [1...x] creates a list counting 1 through x.
Python, 21 - 20% = 16.8 Bytes
lambda x:range(1,x+1)
A range object is basically all the integers from the first argument to the second argument, ecluding the second argument. For example, range(1,10) is the numbers from 1 to 10, excluding 10 (a.k.a 1 to 9). It can actually handle 2**2048.
Rockstar, 44 bytes
listen to N
X's 0
while N-X
build X up
say X
Try it here (Code will need to be pasted in)
QBIC, 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 (?).
Sesos, 3 bytes
Hexdump of generated binary file:
0000000: 16f8ce ...
Size : 3 byte(s)
Assembler:
set numin
set numout
get
jmp
sub 1
fwd 1
add 1
put
rwd 1
;implicit jnz
Brainfuck pseudocode: ,[->+.<]
Oration, 31 bytes
literally, print range(input())
Factor, 16 * 0.8 = 12.8 bytes
[ [1,b] stack. ]
Factor's integer type is a fixnum that automatically promotes to bignum when required.
Explanation
[1,b]Create a range from 1 to a number, inclusive.stack.Prettyprint each element of a sequence, one per line.
PostL 20 bytes
PostL is 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).
Ly, 15 bytes
1>n1-[<:1+>1-]<
More playing with Ly... It uses two stacks, one to hold the list of numbers to print, and the other holds the loop counter.
Push 1 on the default stack, shift stack to the right.
1>
Read the number of iterations onto the stack, decrement by one (since we already pushed the first number)
n1-
Then loop until the counter is 0 with:
[ >1-]<
The body of the loop, just switches back to the stack where the output is accumulating, duplicates the last entry and increments the copy.
<:1+
Finally, printing the output just requires switching to the stack holding the list of numbers to output once the loop ends.
<
Vyxal, 0.8 bytes
ɾ
1-byte builtin. Python's default number type is arbitrary-size integers, so so is Vyxal's. I mean, it won't finish in reasonable time, but if you gave it enough memory and time...
Flurry, 16 - 3.2 = 12.8 bytes
{}{<><<>()>[]}{}
Run example
$ ./flurry -inn -c "{}{<><<>()>[]}{}" 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ ./flurry -inn -c "{}{<><<>()>[]}{}" 1
1
Generates the range using the stack height. Since the task requires 1-based, each stack height should be incremented (produce 2 when stack height is 1, 3 when stack height is 2, etc.).
main = {} f {} -- n f 1
-- Apply f n times to the starting value of 1
f = {<><<>()>[]} -- \x. push(x); return (succ height)
-- Implicitly push the argument and ignore it,
-- returning the value of height + 1
-- so that it can be pushed at the next iteration
Flurry uses Church numerals as the number representation, so it theoretically supports infinite-precision positive integers. But it will take a very long time to actually print the result.
Integral, 8 Bytes
⌡◙▲⌡•▼e
Explanation
(space) Push 1
⌡◙▲⌡ "◙▲", standing for "duplicate, increment" when evaluated
• Swap third-to-top to the top
▼ Decrement
e Repeat that many times
Wren, 15 bytes - 3 = 12 bytes
This is the exact same result before an interation of the thing.
Fn.new{|n|1..n}
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}
Wren, 38 bytes
If this has to be in Standard Output I could do this...
Fn.new{|n|System.print((1..n).toList)}
Brain-Flak, 14 bytes
{(({})[()])}{}
simply pushes the top stack value -1 until it reaches 0. Then it pops the zero and implicitly prints the stack
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
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 RREE- Define label inputrEEEEE- Increment item in stack rrEEEeE- Duplicate item in stack rr reEE-PopGet value from stack r and print popped item as number - Flagrprevents removal of the itemreeE- Output newline
Ree- Goto label input if selected items in both stacks are equal
Basically, loop until the certain value is reached.
Gol><>, 6 - 1.2 (20%) = 4.8 bytes
IFPD|;
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
F#, 36 bytes
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?
Fortran (GFortran), 45 - 20% = 36 bytes
INTEGER(16)I
READ*,R
DO1 I=1,R
1 PRINT*,I
END
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
Stack Cats with -nl, 18 bytes
*(>]>{<:_-!:]}[*)>
Flags are not counted as bytes, but as a separate language as per this Meta consensus.
Flags:
-nto do integer I/O-lto 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
Tcl, 26 bytes
time {puts [incr i]} $argv
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}
MarioLANG, 29 bytes
;
) <
+===="
>:(-[!
=====#
I know my code is sadly super-sad or angry:
>:(
Happy MarioLANG, 46 bytes
;
) <
+======="
> >((-[!
=:)^====#
===
A happier approach:
:)
Non-emotional MarioLANG, 41 bytes
;
) <
+====="
> >(-[!
= "===#
:!
=#
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
Implicit, 10 5 bytes
¡(%ß;)
¡(%ß;) 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)
Charcoal, 4 bytes
I⊕…N
Explanation
I Cast (recursively vectorizes)
⊕ Incremented
…N Range from 0 to next input as number (excluding the number itself)
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.
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)
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.
Explanation
Implicit input n
:: Mode: Sequence 2. Output the sequence up to n
$ Each item in the sequence is the current (1-based) index
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
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.
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)}}
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
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.
Whitespace, 50 * 0.8 = 40 bytes (assumes n is on the stack)
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
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).
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
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>
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.
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
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.
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.
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.
REXX, 27 bytes
arg #
do i=1 to #
say i
end
Maximum number is dependent on NUMERIC DIGITS setting.
><>, 10 bytes
lnao:l(?;:
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.
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)
}
}
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.
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.
><> (Fish), 16 bytes
Solution 1
01+:{:?!;1-rnao!
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!
Labyrinth, 41 29 23 14 bytes
?}):
\ !
@"({
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.
GameMaker Language, 38 bytes
for(i=0;i<argument0;show_message(++i))
D, 55 bytes
(ulong n){import std.stdio;foreach(i;1..n+1)i.writeln;}
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 ofulong. Once again, this is thanks to hstde. - v2.4 -
-2 bytes- Replacedlongwithintdue to the limitations of the capacity ofList<T>, which is capped to the max ofInt32.MaxValuein the implementation. The reason for changing tointcan be found here. You can also explore this limitation in Reference Source. - v2.3 -
-6 bytes- Usingvarinstead ofList<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 toList<>since arrays max size isInt32.MaxValue == 2 ^ 32 - 1 - v1.0 -
105 bytes- Initial release
Ruby 17Byte
1.upto(n){|i|p i}
R, 3 bytes
seq
A built-in function that, when given a single positive integer n as argument, yields 1 to n.
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
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
Dip, 1 - .2 = .8
l
Body must be at least 30 characters; you entered 13.
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')}
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>)1pushes 1 (... → ... 1)(starts an infinite loop&DUPduplicates the ToS (... A → ... A A)" "prints!prints the ToS as a number (... A → ...)&DUPduplicates the ToS (... A → ... A A)&ROTrotates the top three stack elements (... A B C → ... B C A)&DUPduplicates the ToS (... A → ... A A)&ROTrotates 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 positive0pushes 0 (... → ... 0)^breaks out of the innermost loop if the ToS isn't positive (... A → ...)&SWAPswaps the top two stack elements (... A B → ... B A)1pushes 1 (... → ... 1)+adds the top two stack elements (... A B → ... A+B))closes the innermost loop$terminates the program
Cubix, 17 bytes
..U;I0-!@;)wONow!
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 ! . . .
. .
. .
Igets the integer input0push 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 stackwmove ip to the right and carry on. This causes it to drop to the next lineOoutput the top of stack as a numberNpush linefeed (10) to the stackooutput a linefeedwmove 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 stackUuturn to the left onto the-subtraction and resume from there
C#, 47 bytes
l=>{for(int i=1;i<=l;)Console.WriteLine(i++);};
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.
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
Maple, 9 bytes
seq(1..n)
Usage:
> seq(1..10);
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
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
Emacs Lisp, 39 bytes
(lambda(n)(princ(number-sequence 1 n)))
UGL, 14 11 bytes
ic^l_u$ocO^^-:il$d:_locO:
Uses U+0000 as delimiter.
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))
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:
Note: Do NOT run it with this value as it will run for a very long time!
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
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 (%).
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
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.
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
QBASIC, 43 bytes
1 INPUT a
2 FOR b=1 TO a
3 PRINT b
4 NEXT b
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))
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.
Desmos, 60+table bytes
l=\left[1,2,...,\operatorname{floor}\left(a\right)\right]
a=0

I have a set to 0 because the table would contain extra spaces if I didn't. That said, there isn't currently scoring for the table, which I've asked about on meta.
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.
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)}
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.
Scratch, 12 10 bytes

(scoring used)
Asks for the end number, resets, and counts up.
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
Piet, 64 Codels 
With codelsize 20:
Npiet trace images
First loop:
Remaining trace for n=2:
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(Ascii3), however this cannot be properly displayed in this answer so I'll just leave them out. It works in the console:
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):
Ruby, 18 12 bytes
->n{p *1..n}
-3 bytes from Not that Charles, and -3 more from daniero
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)).
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 (edit - I stand corrected, this is not true)iostream library with their std:: namespace are more verbose than C's I/O.
Update (-9 bytes): Learnt that return was optional in C++ thanks to @anatolyg
Oracle SQL 11.2, 44 bytes
SELECT LEVEL FROM DUAL CONNECT BY LEVEL<=: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.
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.
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.
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
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
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
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>
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
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..<>
MarioLANG, 19 bytes
;
)<
+"
:[
(-
>!
=#
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.
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).
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.
Go, 90 bytes
Naive solution:
package main
import ."fmt"
func main(){var n,b uint64
Scan(&n)
for;b<n;b++{Println(b+1)}}
GNU Coreutils, 6 bytes
seq $1
split answer to pure bash, see below...
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.
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." ";
PHP, 32 bytes
for(;$i!=$argv[1];)echo++$i." ";
57 Bytes
$c=function($e){$i=0;while($i!=$e)echo ++$i." ";};$c(10);
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]
Befunge, 21 bytes
&>: v
@^-1:_>,#a:#._
Counts down on the stack, then counts up. Compliance to the 2^64 rule may depend on implementation.
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.
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.
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.
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
Haskell, 10 bytes
f n=[1..n]
Usage example: f 4-> [1,2,3,4].
Bash, 34 Bytes
for ((i=1;i<=$1;i++)); { echo $i;}
Split answer from GNU coreutils, this is pure bash.
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.
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.
Zsh, 12 bytes
echo {1..$1}
This works because variables are expanded before the braces.
Bash, 17 bytes
eval echo {1..$1}
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
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%
}
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";
}
}
Pyke, 1 byte
S
Or 2 bytes without the builtin
mh
#h
Lh
Mathematica, 5 bytes
Range
Simple enough.
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.
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
If a full program is required, 17 bytes:
disp(1:input(''))
10
1 2 3 4 5 6 7 8 9 10
R, 13 bytes
cat(1:scan())
Body must be at least 30 characters.
Cjam, 5 bytes
{,:)}
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.
05AB1E, 1 byte
Code:
L
A more interesting approach:
FN>,
Explanation:
F # For N in range(0, input):
N> # Push N + 1
, # Pop and print with a newline
Pyth, 1 byte
S
Body must be at least 30 characters; you entered 14.







