title: Alternating Random Series Sum To \$N\$

text:
# Question
Title: Alternating Random Series Sum To \$N\$
# Challenge

Given a positive integer \\$N \ge 3\\$, generate an alternating series of \\$N\\$ random numbers within the range \\$\[1, N\]\\$, such that their sum equals \\$N\\$. Expressed mathematically as

$$N = \sum\_{i=1}^{N} (-1)^{i-1} a\_i$$ where \\$a\_i \in \[1,N\]\\$ are random terms.

**Input**

\\$N\\$

**Output**

A string representing the alternating series of \\$N\\$ terms (each prefixed by \\$+\\$ or \\$-\\$) that sum up to \\$N\\$.

**Notes**

Random numbers can be generated using any standard random number generation function. For example, `rand()` in C, `random.randint()` in Python, `Math.random()` in Javascript, etc.,...

# Examples

| N | alternating series |
| --- | --- |
| 3 | +1-1+3 |
| 4 | +4-1+3-2 |
| 5 | +4-2+4-4+3 |
| 6 | +5-1+4-4+3-1 |
| 7 | +6-1+4-7+4-1+2 |
| 8 | +6-7+7-5+7-1+2-1 |
| 9 | +3-7+8-3+2-8+9-2+7 |
| 10 | +10-4+4-2+8-3+1-4+5-5 |
| 11 | +11-7+1-2+2-10+3-5+10-2+10 |
| ... | ... |

# Answer
> 2 votes
# Jelly, 15 bytes

```
ṗḅ-⁼ɗƇ⁸XṚṭNƭ€”+

```

A full program that accepts a positive integer, \\$n\\$, and prints a possible alternating sum, in the given format, with \\$n\\$ terms with absolute values from \\$\[1,N\]\\$.

All possible outputs are equally likely.

**Try it online!**

### How?

```
ṗḅ-⁼ɗƇ⁸XṚṭNƭ€”+ - Main Link: positive integer, n
ṗ               - {[1..n]} Cartisian power {n}
                   -> all length n lists formed of values [1..n]
     Ƈ          - keep those for which:
    ɗ ⁸         -   last three links as a dyad - f(potential, n)
  -             -     literal -1
 ḅ              -     convert {potential} from base -1
                       -> last - penultimate + antepenultimate - ...
   ⁼            -     equals {n}?
       X        - uniform choice
        Ṛ       - reverse
            €   - for each:
           ƭ    -   alternate between:
         ṭ   ”+ -     a) tack to '+'; and
          N     -     b) negate
                - implicit, smashing print

```

# Answer
> 1 votes
# JavaScript (ES6), 74 bytes

```
f=(n,i,s)=>i^n?f(n,-~i,[s]+"+-"[i&1]+-~(Math.random()*n)):eval(s)-n?f(n):s

```

Try it online!

### Commented

```
f = (               // f is a recursive function taking:
  n,                //   n = input
  i,                //   i = counter, initially undefined
  s                 //   s = output string, initially undefined
) =>                //
i ^ n ?             // if i is not equal to n:
  f(                //   do a recursive call:
    n,              //     pass n unchanged
    -~i,            //     increment the counter
    [s] +           //     append to s ...
    "+-"[i & 1] +   //     ... either "+" or "-" according to
                    //     the parity of i
    -~(             //
      Math.random() //     followed by a random integer
      * n           //     in [1, n]
    )               //
  )                 //   end of recursive call
:                   // else:
  eval(s)           //   evaluate the expression
  - n ?             //   if the result is not equal to n:
    f(n)            //     try again
  :                 //   else:
    s               //     stop and return it

```

# Answer
> 1 votes
# Python 3.8 (pre-release), 120 bytes

```
from random import*
def f(n):
 while sum(L:=[s*randint(1,n)for s in(1,-1)*n][:n])-n:1
 return''.join('%+d'%v for v in L)

```

Try it online!

Brute-force method. Generates a list of \\$N\\$ random numbers until their sum is equal to \\$N\\$.

# Answer
> 1 votes
# Google Sheets, 154 bytes

Assuming \\$n\\$ is in \\$A1\\$

```
=LET(F,LAMBDA(F,LET(o,JOIN(,MAKEARRAY(A1,1,LAMBDA(i,_,IF(MOD(i,2),"+","-")&RANDBETWEEN(1,A1)))),IF(A1=SORTN(QUERY(,"select "&MID(o,2,99))),o,F(F)))),F(F))

```

Recursive formula that generates a random sequence. If the sum is \\$n\\$, it returns it, otherwise it generates a new sequence and the process is repeated.

# Answer
> 1 votes
# 05AB1E, 19 bytes

```
L¤ãε(2Å€Ä'+ì]ʒOQ}ΩJ

```

Try it online or verify all possible results for a given input.

`ε(2Å€Ä'+ì]` could alternatively be `ε'+ìι`(.ι}` for the same byte-count:

Try it online or verify all possible results for a given input.

**Explanation:**

```
L             # Push a list in the range [1, (implicit) input]
 ¤            # Push its last item (without popping): the input
  ã           # Cartesian product to have all possible input-sized lists
   ε          # Map over each inner list:
    (         #  Negate all values
     2Å€      #  Then for every 2nd item (0-based index is divisible by 2):
        Ä     #   Absolute value to make the negative value positive again
         '+ì '#   Prepend a "+" instead
   ]          # Close both the every and outer maps
    ʒ         # Filter:
     O        #  Sum the values in the list together
      Q       #  Check whether this is equal to the (implicit) input-integer
    }Ω        # After the filter: keep a random inner list
      J       # Join it together to a single string
              # (which is output implicitly as result)

   ε          # Map over each inner list:
    '+ì      '#  Prepend a "+" before each value
       ι      #  Uninterleave the list into two parts
        `     #  Pop and push both parts separately to the stack
         (    #  Negate the values in the top list
          .ι  #  Interleave the two lists back together
   }          # Close the map

```

# Answer
> 1 votes
# Charcoal, 25 bytes

```
ＮθＷ⁻↨⮌υ±¹θ≔Ｅθ⊕‽θυ⭆υ⁺§+-κι

```

Try it online! Link is to verbose version of code. Explanation:

```
Ｎθ

```

Input `N`.

```
Ｗ⁻↨⮌υ±¹θ

```

Until interpreting the reverse of the predefined empty list as base `-1` results in `N`, ...

```
≔Ｅθ⊕‽θυ

```

... assign `N` random integers in the range `1..N` to the list.

```
⭆υ⁺§+-κι

```

Output the list with `+` and `-` signs inserted as appropriate.

# Answer
> 1 votes
# Pyth, 20 bytes

```
s+V*"+-"QOf!u-HGTQ^S

```

Try it online!

### Explanation

```
s+V*"+-"QOf!u-HGTQ^SQQ    # Implicitly add QQ
                          # Implicitly assign Q = eval(input())
                   SQ     # range(1, Q+1)
                  ^  Q    # repeated cartesian product, Q times
          f               # filter over lambda T
            u-HGTQ        #   reduce T over subtraction with Q as the starting value
           !              #   true if 0
         O                # choose a random value from the list
 +V                       # vectorized addition with
   *"+-"Q                 # "+-" repeated Q times
s                         # join into one string

```

# Answer
> 0 votes
# C (gcc), ~~118~~ 112 bytes

*-6 bytes, thanks to @Arnauld*

```
i=0,s=0,a[];f(n){for(s=0;s-n;)for(i=s=0;i<n;)s+=a[i++]=(i%2*2-1)*~(rand()%n);for(i=0;i<n;)printf("%+d",a[i++]);}

```

Try in online!

---
Tags: code-golf, math, sequence, random
---


title: r flag my Vyxal

text:
# Question
Title: r flag my Vyxal
Vyxal is a stack-based language, meaning that everything operates by popping and pushing values onto a stack. It has a bunch of useful flags, one of which is `r`.

Running a Vyxal program with the `r` flag causes functions to take their elements in reverse order.

For example, the program `5 3 -` means: Push 5 to stack, push 3 onto the stack, and subtract them by popping 3, popping 5, and subtracting the 3 from the 5 to yield 2. But with the `r` flag, it first pops the 5, then the 3, and subtracts 5 from 3 to yield -2.

For this challenge, we will be operating within a much-simplified version of Vyxal.

The digits 0-9 each push themselves to the stack , and lowercase letters are *dyadic* functions, meaning they pop two values from the stack and do something with them, before pushing the result. Everything else does nothing and won't be included in the input.

Your challenge is to take a program with this format and output a program that would do the same thing if the input order of each function is reversed.

This sounds complicated, so let's demonstrate with this example:

```
87a

```

To do this, we simply swap the 8 and the 7 to yield `78a`.

A more complicated example:

```
54a78bc

```

How it works:

```
      c # c is a function taking...
   78b  # This, where:
     b  # b is a function taking
   78   # 7 and 8
        # And...
54a     # This, where:
  a     # a is a function taking...
54      # 5 and 4

```

So to flip it, we just flip the operands of every function:

```
  <-->
<->|| c
|| 78b
54a |
 |  |
 <-->

```

Yielding:

```
87b45ac

```

Which is the result!

Another way to explain this is:

An operator is one of `a-z`

A token is either a single digit, or of the format \[TOKEN\]\[TOKEN\]\[OPERATOR\]

For each token of the format \[TOKEN\]\[TOKEN\]\[OPERATOR\], flip the two tokens.

# Scoring

This is , shortest wins!

# Testcases

You can assume there will always be two values to pop whenever there's a function/operator.

```
123ab => 32a1b
59a34bz => 43b95az
123456abcde => 65a4b3c2d1e
1 => 1
12a53bx7c08d9ef => 980de735b21axcf
12a34bc56d78efg => 87e65df43b21acg

```

As usual, these are created by hand, so please tell me if they're wrong.

# Answer
> 41 votes
# 05AB1E, ~~15~~ ~~12~~ ~~10~~ 9 bytes

-1 byte thanks to Kevin Cruijssen!

This could be 8 bytes without the `l`, but why would I remove that?

```
**vyxal**iŠìì
```

Try it online!

```
v             # for each character y:
 y            #   push y
  x           #   duplicate TOS and double the copy
              #   double is a noop on alphabetic strings
   a          #   is the doubled copy alphabetic / the current char a function?
    l         #   convert the result to lowercase
     i        #   if the command was a function:
              #     stack before: [..., x1, x2, f]
      Š       #     triple-swap:  [..., f, x1, x2]
       ì      #     prepend:      [..., f, x2x1]
        ì     #     prepend:      [..., x2x1f]

```

# Answer
> 13 votes
# brainfuck, 83 bytes

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

```

Try it online!

Maintains a stack of tokens. When an operator is read, append it to the top two tokens on the stack. Each token should be read from right to left.

```
For each character in input:
,[
  Move forward one cell and compare to 85
  [>+>>>++++[>]<-<<[>]<<-]

  Clean up comparison cell
  >>>>[-]<

  If greater than 85 (and thus is operator):
  [
    Remove comparison result
    +

    Append last two tokens together
    <<<<[<]<[[->+<]<]>

    Append operator to end of this token
    +[>]>-[<<[<]>+[>]>-]
  ]
  <
,]
<[.<] output result

```

# Answer
> 12 votes
# Vyxal, ~~18~~ ~~12~~ 8 bytes

```
(n:Ǎ[∇pp

```

Try it Online!

*-5 thanks to @AUsername*

*and -1 to an extra golf on that golf*

*but then another -4 from A Username*

The irony here is that using the `r` flag makes this way too long.

## Explained

```
(n:Ǎ[∇pp
(              # for each character in the input:
 n:Ǎ           #     remove all letters from that character - if this is a letter, it will leave an empty string. Otherwise, it will leave it as-is.
    [          #     if the result isn't empty:
     ∇         #          rotate the top three items
      pp       #          and double prepend

```

# Answer
> 9 votes
# K (ngn/k), <sup>~~34~~</sup> 33 bytes

```
{$[y<58;x,y;(-2_x),,(,/2#|x),y]}/

```

Try it online!

A single neat K scan.

Returns a singleton list with the output.

-1 byte from Traws.

## Explanation

```
{$[y<58;x,y;(-2_x),,(,/|-2#x),y]}/
{                               }/ scan from left
 $[                            ]   if
   y<58;                           current command <58 (is digit)
        x,y                        then join the two
           ;                       otherwise
                    (,/|-2#x)      join the last two commands, reversed
                             ,y    concat with current command
            (-2_x),,               nest, and  join with the rest of the output

```

# Answer
> 8 votes
# JavaScript (ES6),  ~~52~~  49 bytes

Expects an array of characters. Returns a string.

```
a=>a.map(c=>a.push(o=1/c?c:a.pop()+a.pop()+c))&&o

```

Try it online!

### Commented

```
a =>                // a[] = input array, re-used as the stack
  a.map(c =>        // for each character c in a[]:
    a.push(         //   push in the stack ...
      o =           //     ... the new value o:
        1 / c ?     //       if c is a digit:
          c         //         just use c
        :           //       else:
          a.pop() + //         use the concatenation of
          a.pop() + //         the last 2 values from the stack
          c         //         followed by c
    )               //   end of push()
  ) && o            // end of map(); return the last value

```

# Answer
> 7 votes
# Haskell, 55 bytes

```
head.foldl(%)[]
s%x|x<'a'=[x]:s
(a:b:s)%x=(a++b++[x]):s

```

Try it online!

# Answer
> 4 votes
# Charcoal, 14 bytes

```
ＦＳ⊞υ⁺⭆⊗№βι⊟υιυ

```

Try it online! Link is to verbose version of code. Explanation: Based on @Arnauld's answer; for every input character, if it is a letter then pop the top two elements off the result stack and concatenate the three, otherwise just push the digit to the stack, however in Charcoal it turns out to be golfier to pop `N` elements off the result stack where `N` is `2` for a letter and `0` for a digit, and concatenate the character.

```
ＦＳ

```

Loop over the characters of the input string.

```
⊞υ⁺⭆⊗№βι⊟υι

```

Count the number of appearances of the character in the predefined lowercase alphabet, double that, pop that many terms from the predefined empty list, join everything together, and push that to the list.

```
υ

```

Output the final result.

# Answer
> 3 votes
# Stax, 10 bytes

```
ªç8îá/╤╫╬∩

```

Run and debug it

same idea as my K answer.

# Answer
> 3 votes
# Jelly, 17 bytes

```
;ṭ@Ṫ,Ṫ{;ʋ¥ØDi¥}?/

```

Try It Online!

Since the input is guaranteed to be non-empty (clarified by OP), we do not need to reduce from an initial value and can replace `ƒ“”` with `/` (thanks to Leaky Nun for -2 bytes).

There's gotta be a better way to get rid of that `ṭ@Ṫ,Ṫ{;ʋ¥` mess in the middle.

```
;ṭ@Ṫ,Ṫ{;ʋ¥ØDi¥}?/    Main Link
                /    Reduce
               ?     If
              }      - The right argument
            i          - Appears in
          ØD           - "0123456789"
;                    - Append it to the accumulating stack
                     Otherwise
 --======¥           - Previous two; 2,2-chain x (a b) y = x a (x b y)
 ṭ@                  - Append to the accumulator the result of
   -=--=ʋ            - Previous four; 1,2,2,2-chain x (A b c d) y = (x A) b (x c y) d y
   Ṫ                   - Pop the last element off the stack
    ,                  - And pair it with
     Ṫ{                - Pop the last element off the left side (the stack)
       ;               - Append the incoming character

```

# Answer
> 3 votes
# Python 3, ~~81~~ 77 bytes

Python port of the Javascript answer

A recursive lambda might solve this with fewer bytes though.

*-4 bytes thanx to ovs*

```
def f(i,s=[]):
 for c in i:s+=[c<'a'and c or s.pop()+s.pop()+c]
 return s[-1]

```

Try it online!

# Answer
> 3 votes
# Factor, 71 bytes

```
EBNF: A e=e e[a-z]=>[[first3 1string surround]]|[0-9]=>[[1string]];EBNF

```

Try it online!

EBNF definition strikes again :) Defines a function named `A` which takes a string, parses it, and returns its r-flagged version as a string.

(TIO version is slightly older than 0.98 stable, and requires ending `;EBNF` instead of surrounding the body with `[=[ ]=]`. The TIO version happens to be shorter.)

A bit of jankiness comes from the fact that the character class `[0-9]` gives its charcode, not any kind of sequence (array, vector, or string). `1string` is used to keep all intermediate results as strings.

## Ungolfed

```
! If part of a postfix expression,
! parse the two operands and the operator, swap the operands, and concatenate
expr = expr expr [a-z] => [[ first3 1string surround ]]
! Otherwise, take a single digit operand and make it a string
     | [0-9] => [[ 1string ]]

```

# Answer
> 3 votes
# APL (Dyalog Extended), 27 bytes

```
∊{⍺∊⎕D:⍺,⍵⋄(2↑⍵)⍺⊂⍛,2↓⍵}/⍤⌽

```

Try it online!

Straightforward reduction, as in many other answers. Since APL's reduction is from right to left, the reduction is done on the input string reversed. Also, the top of the stack is on the left side, and the stack items are kept nested until the very end (where  flattens the entire structure).

# APL (Dyalog Extended), 34 bytes

```
{⍵[⍒∊{0 2 1⊂⍤+@⍺∊3×⍵}/⌽0,⍸~⍵∊⎕D]}⌽

```

Try it online!

I had an idea of grade-and-indexing, where base 3 numbers define the ordering of elements. It works well, but it is unfortunately slightly longer than the easy solution.

This works by reconstructing the postfix structure based on the indices of operators.

```
Input: '59a34bz' (expected output: '43b95az')

{...}⌽  Reverse the string and pass onto the dfn.
        This has the structure of prefix notation, with args swapped.
        ⍵←'zb43a95'
⍸~⍵∊⎕D  Extract the (1-based) indices of operators.
        v←1 2 5
{...}/⌽0,  Reverse v and reduce on it with the starting value of 0.
           ⍺ gets the indices (1, 2, then 5), and ⍵ is the current vector.
∊3×⍵    Multiply all numbers in ⍵ by 3 and flatten it.
0 2 1⊂⍤+@⍺  Add 0 2 1 to the ⍺-th element in ⍵, creating a nested vector.
        ⍺←1, ⍵←0: ⊂(0 2 1)
        ⍺←2, ⍵←↑: 0 2 1 → 0 6 3 → 0(6 8 7)3
        ⍺←5, ⍵←↑: 0 6 8 7 3 → 0 18 24 21 9 → 0 18 24 21(9 11 10)
⍵[⍒∊...]  Flatten the final result, and sort ⍵ by descending order of that.
        Flatten:   0 18 24 21 9 11 10
        Input(⍵):  z  b  4  3 a  9  5
        Sort desc: 43b95az

```

# Answer
> 3 votes
# Vim, 51 bytes

```
:s/./\r&/g
qq{:/\v(.+)\n(.+)\n(\a)/s//\2\1\3
@qq@qJ

```

Try it online!

The `J` can be omitted if a leading newline is permissible.

# Answer
> 2 votes
# Retina 0.8.2, 29 bytes

```
S`\B
+1`(.+)¶(.+)¶(\D)
$2$1$3

```

Try it online! Link includes test cases. Explanation:

```
S`\B

```

Split each character onto its own line. (Sadly `_S` doesn't seem to do what I want.)

```
+1`(.+)¶(.+)¶(\D)
$2$1$3

```

Processing each operator in turn, prefix it with its reversed operands.

# Answer
> 2 votes
# , 41 bytes

```
[:|.@;((;@;1 0&{);2}.])`;@.(58>3 u:[)/@|.

```

Try it online!

Well, this is quite long and inelegant because of the required boxing in J. Perhaps someone can suggest a better approach.

I believe the current approach is doing more or less the same thing as Razetime's K answer.

# Answer
> 2 votes
# Japt v2.0a0 `-h`, 15 bytes

Input as a character array, output as a string.

```
£pXiUoX²è\a)¬)Ì

```

Try it

```
£pXiUoX²è\a)¬)Ì     :Implicit input of array U
£                   :Map each X
 p                  :  Push to U
  Xi                :    Prepend to X
    Uo              :      Pop this many elements from U
      X²            :        Duplicate X
        è           :        Count occurrences of
         \a         :        RegEx /[a-z]/g
           )        :      End pop
            ¬       :      Join
             )      :  End push
              Ì     :  Last element
                    :Implicit output of last element of resulting array

```

# Answer
> 2 votes
# Python 3, 80 bytes

```
f=lambda i,o=[]:i and f(i[1:],o+[(i[0]>'9'and o.pop()+o.pop()or'')+i[0]])or o[0]

```

Try it online!

# Answer
> 1 votes
# TypeScript's type system, 155 bytes

```
//@ts-ignore
type F<C,S=[]>=C extends[infer T,...infer C]?F<C,T extends`${number}`?[T,...S]:S extends[{},{},...infer N]?[`${S[0]}${S[1]}${T}`,...N]:S>:S[0]

```

Try it at the TS playground

This is a generic type `F<C>` where C is a tuple type of characters, which returns a string literal type.

If the input could instead be a tuple type of elements which are either character or number:

## TypeScript's type system, 144 bytes

```
//@ts-ignore
type G<C,S=[]>=C extends[infer T,...infer C]?G<C,[T,S]extends[string,[{},{},...infer N]]?[`${S[0]}${S[1]}${T}`,...N]:[T,...S]>:S[0]

```

Try it at the TS playground

---
Tags: code-golf, string, parsing, stack, vyxal
---


title: Count up folks!

text:
# Question
Title: Count up folks!
# 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.

# Answer
# 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!
> 67 votes

# Answer
# Pyth, 1 byte

```
S

```

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

# Answer
# 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.
> 16 votes

# Answer
# 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.
> 15 votes

# Answer
# Mathematica, 5 bytes

```
Range

```

Simple enough.
> 14 votes

# Answer
# 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
> 12 votes

# Answer
# GNU Coreutils, 6 bytes

```
seq $1

```

split answer to pure bash, see below...
> 11 votes

# Answer
# 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)}

```
> 10 votes

# Answer
# R, 13 bytes

```
cat(1:scan())

```

Body must be at least 30 characters.
> 10 votes

# Answer
## 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 `long`s *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.
> 9 votes

# Answer
# 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!.
> 8 votes

# Answer
## 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.
> 8 votes

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

# Answer
## 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.
> 7 votes

# Answer
## Haskell, 10 bytes

```
f n=[1..n]

```

Usage example: `f 4`-\> `[1,2,3,4]`.
> 6 votes

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

```
> 6 votes

# Answer
# Pyth - ~~3~~ 2 bytes

*1 bytes saved thanks to @DenkerAffe.*

Without using the builtin.

```
hM

```

Try it online.
> 4 votes

# Answer
## 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!
> 4 votes

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

```
> 4 votes

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

```
> 4 votes

# Answer
# 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` (Ascii `3`), 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):

```
> 4 votes

# Answer
# Oration, 31 bytes

```
literally, print range(input())

```
> 4 votes

# Answer
# 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.
> 3 votes

# Answer
# 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
> 3 votes

# Answer
## 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)
> 3 votes

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

```
> 3 votes

# Answer
## QBASIC, 43 bytes

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

```
> 3 votes

# Answer
# Sesos, 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: `,[->+.<]`
> 3 votes

# Answer
# 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*.
> 2 votes

# Answer
# 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.
> 2 votes

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

```
> 2 votes

# Answer
# Zsh, 12 bytes

```
echo {1..$1}

```

This works because variables are expanded before the braces.
> 2 votes

# Answer
# 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.
> 2 votes

# Answer
## 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]

```
> 2 votes

# Answer
# 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>
```
> 2 votes

# Answer
## 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
> 2 votes

# Answer
# 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.
> 2 votes

# Answer
# /kona, 3 Bytes

```
1+!

```

e.g.

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

```
> 2 votes

# Answer
# 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 (`%`).
> 2 votes

# Answer
# 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
> 2 votes

# Answer
## 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 (`?`).
> 2 votes

# Answer
# 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
> 2 votes

# Answer
# 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.
> 2 votes

# Answer
# 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`.
> 2 votes

# Answer
# 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 `Sub`routine 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)`
> 2 votes

# Answer
# \>\<\>, 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.
> 2 votes

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

```
> 2 votes

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

```
> 2 votes

# Answer
# Integral, 8 Bytes

```
 ⌡◙▲⌡•▼e

```

Try it!

## Explanation

```
          (space) Push 1
 ⌡◙▲⌡     "◙▲", standing for "duplicate, increment" when evaluated
     •    Swap third-to-top to the top
      ▼   Decrement
       e  Repeat that many times

```
> 2 votes

# Answer
# Vyxal, 0.8 bytes

```
ɾ

```

Try it Online!

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...
> 2 votes

# Answer
# Jelly, 1 byte

```
R

```

Try it online!
> 1 votes

# Answer
## 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..<>

```
> 1 votes

# Answer
# Go, 90 bytes

Naive solution:

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

```
> 1 votes

# Answer
# 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`.
> 1 votes

# Answer
# PHP, 32 bytes

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

```

~~57 Bytes~~

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

```~~
> 1 votes

# Answer
## 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%
}

```
> 1 votes

# Answer
# J, 4 bytes

```
>:i.

```

Try it online!
> 1 votes

# Answer
# Bash, 17 bytes

```
eval echo {1..$1}

```
> 1 votes

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

```
> 1 votes

# Answer
# 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
> 1 votes

# Answer
# Befunge, 21 bytes

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

```

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

# Answer
## 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
> 1 votes

# Answer
# 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).
> 1 votes

# Answer
# 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
> 1 votes

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

```
> 1 votes

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

```
> 1 votes

# Answer
# 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
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
## 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
> 1 votes

# Answer
# Oracle SQL 11.2, 44 bytes

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

```
> 1 votes

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

```
> 1 votes

# Answer
# Brachylog, 7 bytes

```
:1:efrw

```

or alternatively

```
:1:efr.

```
> 1 votes

# Answer
# Dip, 1 - .2 = .8

```
l

```

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

# Answer
# 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.
> 1 votes

# Answer
# LibreLogo, 35 bytes

**Code:**

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

```

**Input:**

**Output:**
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# Stax, 1 byte

```
m

```

Run and debug online!

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

# Answer
# 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
> 1 votes

# Answer
# MAWP 1.0, 30 bytes

```
%@_1A[1A~25WWM~]~[!1A]%[:48W;]

```

Output takes a little while for larger numbers.

Try it!
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# Thunno 2, 1 byte

```
R

```

Attempt This Online!

Pretty simple.
> 1 votes

# Answer
# 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)
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# (,) ~~352~~ 243 Chars or \\$243\log\_{256}(3)\approx48.14\\$ Bytes

```
(()(),()()()()()()())(,(((),(())(),,,(()()())()(),(())(()(),,,,(),,(()())))((()()),((()()),,,,(),,(()())()()())((),(,,,,,())))((),(())(),,,((()())),(())())((()()),((),(,,,,,())))),,,(,(()()(),((()))))(()()()),())(,,()((),(())()),,(),,((()())))

```

TIO

If we can take input in unary, 27 Chars or \\$27\log\_{256}(3)\approx\\$5.35 Bytes:

```
(,,((),(())())(),,((()())))

```

TIO
> 1 votes

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

```
> 0 votes

# Answer
# 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*
> 0 votes

# Answer
# GameMaker Language, 38 bytes

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

```
> 0 votes

# Answer
# Bash, 34 Bytes

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

```

Split answer from GNU coreutils, this is pure bash.
> 0 votes

# Answer
# Ruby, ~~18~~ 12 bytes

```
->n{p *1..n}

```

-3 bytes from *Not that Charles*, and -3 more from *daniero*
> 0 votes

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

```
> 0 votes

# Answer
# 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.

```
> 0 votes

# Answer
# Scratch, ~~12~~ 10 bytes

(scoring used)
Asks for the end number, resets, and counts up.
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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!
> 0 votes

# Answer
## Emacs Lisp, 39 bytes

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

```
> 0 votes

# Answer
# Jellyfish, 5 bytes

```
p`>ri

```

Try it online!

### Explanation

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

```
> 0 votes

# Answer
## C#, 47 bytes

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

```
> 0 votes

# Answer
# 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
> 0 votes

# Answer
# 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')}`
> 0 votes

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

```
> 0 votes

# Answer
# 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
> 0 votes

# Answer
# R, 3 bytes

```
seq

```

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

# Answer
# 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).

```
> 0 votes

# Answer
# D, 55 bytes

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

```
> 0 votes

# Answer
## \>\<\> (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!
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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)
    }
}

```
> 0 votes

# Answer
## REXX, 27 bytes

```
arg #
do i=1 to #
  say i
  end

```

Maximum number is dependent on `NUMERIC DIGITS` setting.
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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`.
> 0 votes

# Answer
# Newline NC 23 bytes

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

```

`\n`is a newline. Try it online Input is in the variable numbers, that is STDIN for newline.
> 0 votes

# Answer
# Japt, 1 byte

Outputs an array of integers.

```
õ

```

Try it online
> 0 votes

# Answer
# 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>
```
> 0 votes

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

```
> 0 votes

# Answer
# 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).
> 0 votes

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

```
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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)}}

```
> 0 votes

# Answer
## 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
> 0 votes

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

```
> 0 votes

# Answer
# Retina, 18 bytes

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

```

Try it online!
> 0 votes

# Answer
# 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.
> 0 votes

# Answer
# 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)
> 0 votes

# Answer
# Charcoal, 4 bytes

```
Ｉ⊕…Ｎ

```

Try it online!

## Explanation

```
Ｉ     Cast (recursively vectorizes)
  ⊕    Incremented
   …Ｎ Range from 0 to next input as number (excluding the number itself)

```
> 0 votes

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

```
> 0 votes

# Answer
## Canvas, ~~2~~ 1 byte~~s~~

Try it online!
> 0 votes

# Answer
# 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!
> 0 votes

# Answer
# 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!
> 0 votes

# Answer
# 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?
> 0 votes

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

```
> 0 votes

# Answer
# 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!
> 0 votes

# Answer
# Ly, 15 bytes

```
1>n1-[<:1+>1-]<

```

Try it online!

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.

```
              <

```
> 0 votes

# Answer
# Factor, 16 * 0.8 = 12.8 bytes

```
[ [1,b] stack. ]

```

Try it online!

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.
> 0 votes

# Answer
# , 5 bytes

```
>:@i.

```

Try it online!
> 0 votes

# Answer
# 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`.
> 0 votes

# Answer
# Go, 44 - 20% = 35.2 bytes

```
func(n uint64){for i:=0;i<n;i++{println(i)}}

```

Attempt This Online!

Prints to STDERR, with each number on its own line.
> 0 votes

# Answer
# Rattle, 9 bytes

```
|!s=[+p]~

```

Try it Online!

# 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

```
> 0 votes

# Answer
# Maple, 9 bytes

```
seq(1..n)

```

Usage:

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

```
> -1 votes

# Answer
# Ruby 17Byte

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

```
> -1 votes

---
Tags: code-golf, sequence
---


# Question
Title: Number of cigarettes that can be made from a given number of butts
## Assumption

A cigarette can be made by combining four cigarette butts. Cigarette butts last infinitely until smoked.

## Explanation

Say you have 31 butts. That means, you can make 7 cigarettes from 28 butts and have 3 left over.
Now, these 7 cigarettes will yield 7 butts when you're done smoking them. That means you have 3 + 7 = 10 butts.
These 10 butts make 2 new cigarettes and 2 butts are left over, but the two new cigarettes yield 2 more butts, for a total of 4 butts remaining.
Therefore, 31 butts means you can smoke 10 cigarettes in total.

## The question

Given a number of butts `N`, where `0 <= N < 1000000`, find out how many cigarettes can be made from those `N` butts.

### Input format

A single line containing the integer N.

### Output format

Print the number of cigarettes that can be made from N butts.

## Test cases

1. Input:
```
31

```
Output:
```
10

```
2. Input:
```
7

```
Output:
```
2

```
3. Input:
```
4

```
Output:
```
1

```

For `N <= 3`, the output should be 0.

My personal best C solution is 66 bytes. A friend helped reduce it to 63 bytes, and someone else I know was able to come up with a 43-byte solution (also in C).

# Answer
# JavaScript (ES6), 10 bytes

Unless I'm missing something, this boils down to:

```
n=>~-n/3|0

```

Try it online!

Or **9 bytes** with BigInts.
> 7 votes

# Answer
# C (gcc), 14 bytes

```
f(n){n=~-n/3;}

```

Try it online!

*Port of Arnauld's JavaScript answer*
> 4 votes

# Answer
# Charcoal, 6 bytes

```
Ｉ÷↔⊖Ｎ³

```

Try it online! Link is to verbose version of code. Explanation:

```
    Ｎ   Input as a number
   ⊖    Decremented
  ↔     Absolute value
 ÷      Integer divided by
     ³  Literal integer `3`
Ｉ       Cast to string
        Implicitly print

```
> 3 votes

# Answer
# Jelly, 4 bytes

```
s3ṖL

```

A monadic Link that accepts the number of butts and yields the number of cigarettes.

**Try it online!** Or see the test-suite.

##### How?

Group the butts into threes, and consider the last up to three butts your "Pile". Take each of the other groups of three butts in turn and combine with one of your Pile, replenishing your Pile with the generated butt.

```
s3ṖL - Link: integer, Butts
s3   - split into threes (rightmost lacking if necessary)
  Ṗ  - pop (remove your Pile from the right side)
   L - length

```
> 2 votes

# Answer
# Funge-98, 12 bytes

```
&:1-3/\!!*.@

```

Try it online!
> 2 votes

# Answer
# 05AB1E, 3 bytes

```
<3÷

```

Try it online or verify all test cases.

**Explanation:**

```
<    # Decrease the (implicit) input-integer by 1
 3÷  # Then integer-divide it by 3
     # (after which the result is output implicitly)

```

Note: Integer-division in 05AB1E (built in Elixir) will round towards 0 for negative values, so this works even for \\$n=0\\$.
> 2 votes

# Answer
# Retina 0.8.2, 11 bytes

```
.+
$*
...\B

```

Try it online! Link is to verbose version of code. Explanation:

```
.+
$*

```

Convert to unary.

```
...\B

```

For every three butts, if there is at least one other butt left over, you can smoke another cigarette, which will leave a butt, which therefore replenishes the butt left over. So this just counts the number of groups of three butts while still leaving at least one butt left over.
> 1 votes

# Answer
# Rattle, 6 bytes

```
|-/3R1

```

Try it Online!

# Explanation

```
|         take input
 -        decrement
  /3      divide by 3
    R1    reformat as int, implicit output

```

Alternatively, the code could be `|!-/3i`
> 1 votes

---
Tags: code-golf, math, number, arithmetic, recursion
---