[Question]
  [
Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). If the source code is duplicated the output must remain the same. The tricky part is that if the source code is typed three times **(triplicated?)** the output will be multiplied by 3.
# Rules
* You must build a **full program**. That is, your output has to be printed to STDOUT.
* The initial source must be at least 1 byte long.
* Both the integers must be in base 10 (outputting them in any other base or with scientific notation is forbidden).
* Your program must *not* take input (or have an unused, empty input).
* Outputting the integers with trailing / leading spaces is allowed.
* Leading Zeroes are allowed only if the numbers of digits is consistent eg: 001 - 001 - 003 or 004 - 004 - 012
* You may not assume a newline between copies of your source.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest (original) code *in each language* wins!
* **[Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default)** apply.
### Example
Let's say your source code is `Abc` and its corresponding output is `4`. If I write `AbcAbc` instead and run it, the output must still be `4`. However if I write `AbcAbcAbc` and run it, the output must be `12`.
---
~~Shamelessly stolen~~ Derived from Mr. Xcoder's [challenge](https://codegolf.stackexchange.com/questions/132558/i-double-the-source-you-double-the-output)
  
[Answer]
## [Wumpus](https://github.com/m-ender/wumpus), 6 bytes
```
{~)
@O
```
[Try it online!](https://tio.run/##Ky/NLSgt/v@/uk6Ty8H//38A "Wumpus – Try It Online")  
[Try it doubled!](https://tio.run/##Ky/NLSgt/v@/uk6Ty8EfQv7/DwA "Wumpus – Try It Online")  
[Try it tripled!](https://tio.run/##Ky/NLSgt/v@/uk6Ty8Efmfz/HwA "Wumpus – Try It Online")
Prints `1` and `3`.
### Explanation
I found a ton of 6-byte solutions by brute force search, but none for 5 bytes. That doesn't necessarily mean there aren't any at 5 bytes but they'd probably use weird characters or something.
I ended up picking this solution because it doesn't print any leading zeros (most of them do) and it has some interesting control flow. Let's start with the single program:
[![enter image description here](https://i.stack.imgur.com/da5X5.png)](https://i.stack.imgur.com/da5X5.png)
So the executed code is:
```
{~)O@
{   Turn the IP left by 60°.
~   Swap two implicit zeros on the stack, does nothing.
)   Increment the top zero to 1.
O   Print it.
@   Terminate the program.
```
Easy enough. Now the doubled program. Since the first line gets appended onto the second line, the grid extends to width 5 (and height 3) which changes the control flow significantly:
[![enter image description here](https://i.stack.imgur.com/2lXt0.png)](https://i.stack.imgur.com/2lXt0.png)
The IP goes around that loop exactly once, so the executed code is:
```
{~){~)){~O@
{~) As before, we end up with a 1 on top of the stack.
{   Turn left by 60° again.
~   Swap the 1 with the 0 underneath.
))  Increment the zero to 2.
{   Turn left by 60° again.
~   Swap the 2 with the 1 underneath.
O   Print the 1.
@   Terminate the program.
```
Finally, the tripled program is quite similar to the doubled one, but we get a couple more important commands onto that third line:
[![enter image description here](https://i.stack.imgur.com/aMq4d.png)](https://i.stack.imgur.com/aMq4d.png)
So the executed code is:
```
{~){~)){~~)O@
{~){~)){~
    As before. We end up with a 1 on top of the stack and a 2 underneath.
~   Swap the 1 with the 2 underneath.
)   Increment the 2 to a 3.
O   Print the 3.
@   Terminate the program.
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 5 bytes
```
KΣK+1
```
[Try it online!](https://tio.run/##yygtzv7/3/vcYm9tw///AQ "Husk – Try It Online")
[Repeated twice!](https://tio.run/##yygtzv7/3/vcYm9tQwj5/z8A)
[Repeated thrice!](https://tio.run/##yygtzv7/3/vcYm9tQ2Ty/38A)
## Explanation
It's quite difficult to construct a repeatable program in Husk.
Because the type system forbids a function that can be applied to itself, I have to somehow allow the first part to evaluate to a function, and the remainder to evaluate to a value, and the types of existing built-ins are designed to prevent this kind of ambiguity.
The tokens of the program are
* `K`, which constructs a constant function. `K a b` is equivalent to `a`.
* `Σ`, which takes an integer **n** and returns the **n**th triangular number.
* `+`, which adds two numbers.
* `1`, which is the literal 1.
The original program is interpreted like this:
```
   K Σ (K+) 1
== Σ 1
== 1
```
The `(K+)` is a nonsensical function that gets eaten by the first `K`.
The twice repeated program is interpreted like this:
```
   K Σ (K+1KΣK+) 1
== Σ 1
== 1
```
The function in parentheses is again eaten by the first `K`.
The thrice repeated program is interpreted like this:
```
   K (Σ (K (+1) (KΣK+) 1)) (KΣK+1)
== Σ (K (+1) (KΣK+) 1)
== Σ ((+1) 1)
== Σ (+1 1)
== Σ 2
== 3
```
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 5 bytes
```
)<@OP
```
Try it online: [once](https://tio.run/##Sy5Nyqz4/1/TxsE/4P9/AA "Cubix – Try It Online"), [twice](https://tio.run/##Sy5Nyqz4/1/TxsE/AEz8/w8A "Cubix – Try It Online"), [thrice](https://tio.run/##Sy5Nyqz4/1/TxsE/AEH8/w8A "Cubix – Try It Online").
---
## Explanation
Cubix is a stack-based language whose instructions are wrapped around the outside of a cube. Important to note is that the stack is initially filled with infinite zeroes, which allows us to "pull values out of thin air" with operators rather than pushing them explicitly.
I must admit that this was found by a brute-forcer; I never would have found it on my own. In fact, @MartinEnder was the one who asked me to try brute-forcing, as he had been looking for this solution without luck. This is the only solution the brute-forcer found, and I do believe it is the one and only shortest solution in Cubix.
### Single program
[Watch it run!](http://ethproductions.github.io/cubix/?code=KTxAT1A=&input=&speed=2)
The original program fits on a unit cube. Here's the unfolded net:
```
  )
< @ O P
  .
```
The IP (instruction pointer) starts on the leftmost face (the `<`) headed east. The `<` immediately points it west, and it wraps around to the `P`. `P` is exponentiation, and since there's nothing on the stack, the interpreter pulls out two **0**s and calculates **00**, which is **1** according to JavaScript. `O` then prints this value, and `@` ends the program.
### Double program
[Watch it run!](http://ethproductions.github.io/cubix/?code=KTxAT1ApPEBPUA==&input=&speed=2)
```
)<@OP)<@OP
```
The 10-byte program is too long to fit onto a unit cube, and so it is expanded to a size-2 cube:
```
    ) <
    @ O
P ) < @ O P . .
. . . . . . . .
    . .
    . .
```
As before, the IP starts out at the top-left of the left-most face. This time, the very first instruction is `P`, which pushes a **1** as before. Next is `)`, which increments the top item, turning it into a **2**. Then `<` turns the IP around, and it hits the `)` again, transforming the **2** into a **3**.
Here's where it gets interesting. `P` raises the second-from-top item to the power of the first item, which gives **03 = 0**. Then the IP wraps around to the rightmost face and passes through two no-ops `.` before hitting another `P`. Here we see another quirk of Cubix: binary operators (such as `P`) don't remove their operands from the stack. So since the stack is now `[3, 0]`, we calculate **30 = 1**, which `O` outputs, and `@` terminates the program.
### Triple program
[Watch it run!](http://ethproductions.github.io/cubix/?code=KTxAT1ApPEBPUCk8QE9Q&input=&speed=2)
```
)<@OP)<@OP)<@OP
```
As with the double program, the triple can fit on a size-2 cube:
```
    ) <
    @ O
P ) < @ O P ) <
@ O P . . . . .
    . .
    . .
```
This program starts out in the same way as the previous: `P` pushes **1**, `)` increments, `<` points the IP west, `)` increments again, and `P` now pushes **0**. The IP is then wrapped around to the `<` on the rightmost face, which does nothing since the IP is already pointed west.
Here is the one difference from the double program: the `)` increments the **0** on top of the stack to a **1**. When `P` performs its magic again, this time it calculates **31 = 3**. `O` outputs and `@` terminates, and we prove conclusively that the third time is indeed the charm.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 5 bytes
```
»‘µ*Ḃ
```
[Try it online!](https://tio.run/##y0rNyan8///Q7kcNMw5t1Xq4o@n/fwA "Jelly – Try It Online")
[Try it doubled!](https://tio.run/##y0rNyan8///Q7kcNMw5t1Xq4owmJ@f8/AA "Jelly – Try It Online")
[Try it tripled!](https://tio.run/##y0rNyan8///Q7kcNMw5t1Xq4owk78/9/AA "Jelly – Try It Online")
### How it works
```
»‘µ*Ḃ            Main link. No arguments. Implicit argument: x = 0
 ‘               Increment; yield x + 1 = 1.
»                Take the maximum of x and 1. Yields 1.
  µ              Begin a new, monadic chain. Argument: y = 1
    Ḃ            Bit; yield 1 if y is odd, 0 if it is even. Yields 1.
   *             Power; yield y**1 = 1.
```
```
»‘µ*Ḃ»‘µ*Ḃ       Main link.
»‘µ*Ḃ            As before.
      ‘          Increment; yield y + 1 = 2.
     »           Take the maximum of 1 and 2. Yields 2.
       µ         Begin a new, monadic chain. Argument: z = 2
         Ḃ       Bit; yield 1 if z is odd, 0 if it is even. Yields 0.
        *        Power; yield z**0 = 1.
```
```
»‘µ*Ḃ»‘µ*Ḃ»‘µ*Ḃ  Main link.
»‘µ*Ḃ»‘µ*Ḃ       As before.
           ‘     Increment; yield z + 1 = 3.
          »      Take the maximum of 1 and 3. Yields 3.
            µ    Begin a new, monadic chain. Argument: w = 3
              Ḃ  Bit; yield 1 if w is odd, 0 if it is even. Yields 1.
             *   Power; yield w**1 = 3.
```
[Answer]
# [Haskell](https://www.haskell.org/), 24 bytes
```
main=print.div 3$4
 -1--
```
Prints `1`: [Try it online!](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0QvJbNMwVjFhEtB11BX9/9/AA "Haskell – Try It Online")
```
main=print.div 3$4
 -1--main=print.div 3$4
 -1--
```
Also prints `1`: [Try it online!](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0QvJbNMwVjFhEtB11BXF5f4//8A "Haskell – Try It Online")
```
main=print.div 3$4
 -1--main=print.div 3$4
 -1--main=print.div 3$4
 -1--
```
Prints `3`: [Try it online!](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0QvJbNMwVjFhEtB11BXl1Tx//8B "Haskell – Try It Online")
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 10 bytes
```
<>([]{}())
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/38ZOIzq2ulZDU/P/fwA "Brain-Flak – Try It Online")
[Try it doubled!](https://tio.run/##SypKzMzTTctJzP7/38ZOIzq2ulZDUxPB@v8fAA "Brain-Flak – Try It Online")
[Try it tripled!](https://tio.run/##SypKzMzTTctJzP7/38ZOIzq2ulZDUxMb6/9/AA "Brain-Flak – Try It Online")
Explanation:
```
#Toggle stacks
<>
#Push
(
    #Stack-height (initially 0) + 
    []
    #The TOS (initially 0) + 
    {}
    #1
    ()
)
```
When we run this once, it will put `(0 + 0 + 1) == 1` onto the alternate stack. Ran a second time, it puts the same onto the main stack. Run a *third* time however, it evaluates to `(1 + 1 + 1) == 3`, and pushes that to the alternate stack and implicitly prints.
[Answer]
## SQL, ~~25~~ ~~24~~ 23 bytes
(**-1 Byte** *Removed a mistyped character that was always commented out and doing nothing*)  
(**-1 Byte** *Changed `SELECT` to `PRINT` as recommended by Razvan Socol*) 
```
PRINT 2/*
*2+1--*/-1
--
```
**How it works:**  
In SQL, you can comment out the comment tags, like so:
```
/*
'Comment'--*/
```
vs 
```
--/*
'Not Comment'--*/
```
*Code on 1 line with comments excluded:*  
First iteration: `SELECT 2-1` Output: `1`  
Second iteration: `SELECT 2-1*2+1` Output: `1`  
Third iteration: `SELECT 2-1*2+1*2+1` Output: `3`
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGLOnline), ~~7~~ ~~5~~ 4 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
ē»«I
```
[Try it here!](https://dzaima.github.io/SOGLOnline/?code=JXUwMTEzJUJCJUFCSQ__,v=0.12)
[Try it doubled!](https://dzaima.github.io/SOGLOnline/?code=JXUwMTEzJUJCJUFCSSV1MDExMyVCQiVBQkk_,v=0.12)
[Try it tripled!](https://dzaima.github.io/SOGLOnline/?code=JXUwMTEzJUJCJUFCSSV1MDExMyVCQiVBQkkldTAxMTMlQkIlQUJJ,v=0.12)
Explanation:
```
ē»«I
ē     push counter, then increment it.
      First time running this will push 0, then 1, then 2.
             TOS on each: 0  1  2
 »    floor divide by 2   0  0  1
  «   multiply by 2       0  0  2
   I  and increment       1  1  3
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~6~~ 5 bytes
```
.gDÈ+
```
[Try it online!](https://tio.run/##MzBNTDJM/f9fL93lcIf2//8A "05AB1E – Try It Online")
or [Try it doubled!](https://tio.run/##MzBNTDJM/f9fL93lcIc2hPz/HwA) or [Try it tripled!](https://tio.run/##MzBNTDJM/f9fL93lcIc2Mvn/PwA)
**Explanation**
```
.g     # push length of stack
  D    # duplicate
   È   # check if even
    +  # add
```
**Single: `0 + (0 % 2 == 0) -> 1`  
Double: `1 + (1 % 2 == 0) -> 1`  
Triple: `2 + (2 % 2 == 0) -> 3`**
[Answer]
# [Lost](https://github.com/Wheatwizard/Lost), 38 bytes
```
\\<<<<</<<<<>
2>((1+@>?!^%^
.........v
```
[Try it online!](https://tio.run/##y8kvLvn/PybGBgT0QYQdl5GdhoahtoOdvWKcahyXHgyU/f//XzcQAA "Lost – Try It Online")
```
\\<<<<</<<<<>
2>((1+@>?!^%^
.........v\\<<<<</<<<<>
2>((1+@>?!^%^
.........v
```
[Try it online!](https://tio.run/##y8kvLvn/PybGBgT0QYQdl5GdhoahtoOdvWKcahyXHgyUEafq////uoEA "Lost – Try It Online")
```
\\<<<<</<<<<>
2>((1+@>?!^%^
.........v\\<<<<</<<<<>
2>((1+@>?!^%^
.........v\\<<<<</<<<<>
2>((1+@>?!^%^
.........v
```
[Try it online!](https://tio.run/##y8kvLvn/PybGBgT0QYQdl5GdhoahtoOdvWKcahyXHgyUUVPV////dQMB "Lost – Try It Online")
## Explanation
Lost is a very interesting language for this challenge. The usual Lost technique is to build a "trap". A trap is a section of the program designed to catch all the ips in one place so that their stacks can be cleared and they can be controlled to go in a specific direction. This makes writing programs in Lost a lot more manageable. However since the program is duplicated we need to avoid trap duplication as well. This requires us to design a new trap that works properly but when duplicated only one of the traps works. My basic idea here is the following
```
v<<<<>
>%?!^^
```
While the stack is non-empty the `?` will remove a item and cause it to jump back to the begining if that item is non-zero. The key here is that when this stacks the `^^`s line up
```
v<<<<>
>%?!^^v<<<<>
>%?!^^v<<<<>
>%?!^^v<<<<>
>%?!^^v<<<<>
>%?!^^
```
Meaning that no matter how you enter you will always exit in the same place.
From here we can attempt to implement the same idea from [my Klein answer](https://codegolf.stackexchange.com/a/158056/56656).
```
\\<<<<<v<<<<>
2>((1+@>?!^%^
```
The backbone of our program is the left had side which pushes a number of `2`s. Each time we add a copy of the program another `2` gets added to the backbone of the program meaning an additional 2 is pushed to the stack. Once it goes off the bottom it bounces through `\\>` and executes the code
```
((1+@
```
This removes the first 2 stack items, adds one to the whatever is left, and exits. Once our backbone has 3 2s we will add 1 and get 3, if we have any less than 3 items we will just discard the entire stack and return 1.
Now the only problem left is that the `!` in our program can cause an infinite loop. If the ip starts on `!` going upwards it will jump and land right back where it was. This means we have to add another line underneath to prevent the loop.
```
\\<<<<</<<<<>
2>((1+@>?!^%^
.........^
```
This has the slight problem of putting some slashes in between our `^`s in the trap. However, rather miraculously, everything works out. Our ips bounce around properly so that it doesn't make a difference.
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 9 bytes
```
\5 n;
\\1
```
[Try it online!](https://tio.run/##S8sszvj/P8ZUIc@aKybG8P9/AA "><> – Try It Online")
[Try it doubled!](https://tio.run/##S8sszvj/P8ZUIc@aKybGEM74/x8A "><> – Try It Online")
[Try it tripled!](https://tio.run/##S8sszvj/P8ZUIc@aKybGEJPx/z8A "><> – Try It Online")
I found this sort of by luck, using the philosophy that "if you make the fish's path convoluted enough, eventually something will work". The original and doubled versions print a 5, and the tripled version prints 1 then 5 to make 15 = 3×5. Here are the multiplied versions, for your perusal:
```
\5 n;
\\1\5 n;
\\1
```
```
\5 n;
\\1\5 n;
\\1\5 n;
\\1
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~46 45~~ 39 bytes
Inspired by [Halvard's answer](https://codegolf.stackexchange.com/a/140886/59487). I'm glad that my challenge inspired a new one, which I find even more interesting. Saved 6 bytes thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen).
```
print open(__file__,"a").tell()/79*3|1#
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v6AoM69EIb8gNU8jPj4tMyc1Pl5HKVFJU68kNSdHQ1Pf3FLLuMZQ@f9/AA "Python 2 – Try it online!")
[Try it doubled!](https://tio.run/##K6gsycjPM/r/v6AoM69EIb8gNU8jPj4tMyc1Pl5HKVFJU68kNSdHQ1Pf3FLLuMZQmUhl//8DAA "Python 2 – Try It Online")
[Try it tripled!](https://tio.run/##K6gsycjPM/r/v6AoM69EIb8gNU8jPj4tMyc1Pl5HKVFJU68kNSdHQ1Pf3FLLuMZQmbrK/v8HAA "Python 2 – Try It Online")
## How it works (outdated)
```
k=open(__file__,"a").tell() # Read the source code in "append" mode and get its length.
                            # Assign it to a variable k.
;print k>>(k==90)#          # Print k, with the bits shifted to the right by 1 if k
                            # is equal to 90, or without being shifted at all overwise.
                            # By shifting the bits of a number to the right by 1 (>>1),
                            # we basically halve it.
```
When it is doubled, the length becomes **90**, but the new code is ignored thanks to the `#`, so `k==90` evaluates to `True`. Booleans are subclasses of integers in Python, so `k>>True` is equivalent to `k>>1`, which is essentially **k / 2 = 45**. When it is tripled, the new code is again ignored, hence the new length is **135**, which doesn't get shifted because `k==90` evaluates to `False`, so `k>>(k==90) ⟶ k>>(135==90) ⟶ k>>False ⟶ k>>0 ⟶ k`, and **k** is printed as-is.
---
# [Python 2](https://docs.python.org/2/), 36 bytes
This was a suggestion by Aidan F. Pierce at 38 bytes, and I golfed it by 2 bytes. I’m not posting this as my main solution because I didn’t come up with it by myself.
```
0and""
True+=1
print True>3and 3or 1
```
[Try it online!](https://tio.run/##K6gsycjPM/r/3yAxL0VJiSukqDRV29aQq6AoM69EAcSzMwbKKBjnFykY/v8PAA "Python 2 – Try It Online")
[Try it doubled!](https://tio.run/##K6gsycjPM/r/3yAxL0VJiSukqDRV29aQq6AoM69EAcSzMwbKKBjnFykYEqPm/38A "Python 2 – Try It Online")
[Try it tripled!](https://tio.run/##K6gsycjPM/r/3yAxL0VJiSukqDRV29aQq6AoM69EAcSzMwbKKBjnFykYUkvN//8A "Python 2 – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~37~~ ~~31~~ 28 bytes
Thanks to [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe) for golfing off the final 3 bytes.
```
length(readLines())%/%2*2+1
```
(with a trailing newline).
[Try it once!](https://tio.run/##K/r/Pyc1L70kQ6MoNTHFJzMvtVhDU1NVX9VIy0jbkOv/fwA "R – Try It Online")
[Try it twice!](https://tio.run/##K/r/Pyc1L70kQ6MoNTHFJzMvtVhDU1NVX9VIy0jbkAuf3P//AA "R – Try It Online")
[Try it thrice!](https://tio.run/##K/r/Pyc1L70kQ6MoNTHFJzMvtVhDU1NVX9VIy0jbkItcuf//AQ "R – Try It Online")
This uses the `readLines()` trick from [Giuseppe's answer to the 8-ball challenge](https://codegolf.stackexchange.com/questions/157546/create-a-magic-8-ball/157613#157613), where `stdin` redirects to the source file. This code basically just counts up how many lines exist below the first line and outputs `1` if there are 1 or 3 lines (i.e. code is single or doubled), or `3` if there are 5 lines (i.e. code is tripled).
[Answer]
## [C (gcc)](https://gcc.gnu.org/), 107 bytes
My first submission in C (gcc). Way too long ...
```
i;
#ifdef c
#define c
#ifdef b
i=2;
#else
#define b
#endif
#else
#define c main(){putchar(i+49);}
#endif
c
```
TIO links: [single](https://tio.run/##S9ZNT07@/z/Tmks5My0lNU0hmUsZSGXmpYJYEKEkrkxbI6CC1JziVLhsEpCfl5KZhiacrJCbmJmnoVldUFqSnJFYpJGpbWKpaV0LUw20CwA "C (gcc) – Try It Online"), [double](https://tio.run/##S9ZNT07@/z/Tmks5My0lNU0hmUsZSGXmpYJYEKEkrkxbI6CC1JziVLhsEpCfl5KZhiacrJCbmJmnoVldUFqSnJFYpJGpbWKpaV0LU53MRT@r/v8HAA "C (gcc) – Try It Online"), [triple](https://tio.run/##S9ZNT07@/z/Tmks5My0lNU0hmUsZSGXmpYJYEKEkrkxbI6CC1JziVLhsEpCfl5KZhiacrJCbmJmnoVldUFqSnJFYpJGpbWKpaV0LU53MNSyt@v8fAA "C (gcc) – Try It Online").
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 5 bytes
```
|dhH^
```
[Run and debug online!](https://staxlang.xyz/#c=%7CdhH%5E&a=1) · [Doubled](https://staxlang.xyz/#c=%7CdhH%5E%7CdhH%5E&a=1) · [Tripled](https://staxlang.xyz/#c=%7CdhH%5E%7CdhH%5E%7CdhH%5E&a=1)
## Explanation
```
|dhH^
|d       Push Current stack depth `d`, originally 0
         Doubled -> 1, Tripled -> 2
  hH^    Map d to 2*(floor(d/2))+1
         Implicit print
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~95~~ ~~91~~ 85 bytes
```
#ifndef a
#define a-1
main(){puts(3
#include __FILE__
?"1":"3");}
#define a
#endif
a
```
[Try it online!](https://tio.run/##S9ZNT07@/185My0vJTVNIZFLGUhl5qUqJOoacuUmZuZpaFYXlJYUaxhzKWfmJeeUpqQqxMe7efq4xsdz2SsZKlkpGStpWtci9HEpp@alZKZxJXL9/w8A "C (gcc) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~8~~ ~~6~~ 5 bytes
*-1 byte thanks to @ETHproductions*
```
°U-v
```
## Explanation:
```
°U-v
 U     # variable U=0                # U=0
°U     # ++U                         # U=1
  -    # minus:
   v   #   1 if U is divisible by 2  
       #     else
       #   0                         # U=1
```
[This evaluates to `1-0 = 1`](https://tio.run/##y0osKPn//9CGUN0yrv//AQ)
[Doubled evaluates to `2-1 = 1`](https://tio.run/##y0osKPn//9CGUN0yLgj5/z8A)
[Tripled evaluates to `3-0 = 3`](https://tio.run/##y0osKPn//9CGUN0yLmTy/38A)
[Answer]
# Pure Bash (no `wc` or other external utils), 27
```
trap echo\ $[a++&2|1] EXIT
```
* [Try it once.](https://tio.run/##S0oszvj/v6QosUAhNTkjP0ZBJTpRW1vNqMYwVsE1wjOE6/9/AA)
* [Try it twice.](https://tio.run/##S0oszvj/v6QosUAhNTkjP0ZBJTpRW1vNqMYwVsE1wjOEC4/U//8A)
* [Try it thrice.](https://tio.run/##S0oszvj/v6QosUAhNTkjP0ZBJTpRW1vNqMYwVsE1wjOEizyp//8B)
[Answer]
# [Perl 5](https://www.perl.org/), ~~18~~ ~~15~~ ~~13~~ ~~12~~ 11 bytes
-3 bytes thanks to [nwellnhof](https://codegolf.stackexchange.com/users/9296/nwellnhof)
```
say 1|
+.7#
```
Once [Try it online!](https://tio.run/##K0gtyjH9/784sVLBsIZLW89c@f//f/kFJZn5ecX/dX1N9QwN9AwA "Perl 5 – Try It Online")
Twice [Try it online!](https://tio.run/##K0gtyjH9/784sVLBsIZLW89cGYn5//@//IKSzPy84v@6vqZ6hgZ6BgA "Perl 5 – Try It Online")
Thrice [Try it online!](https://tio.run/##K0gtyjH9/784sVLBsIZLW89cGTvz//9/@QUlmfl5xf91fU31DA30DAA "Perl 5 – Try It Online")
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~10 9~~ 8 bytes
```
562gn|
```
[Try it online!](https://tio.run/##S8sszvj/39TMKD2vhpHr/38A "><> – Try It Online")
[Try it doubled!](https://tio.run/##S8sszvj/39TMKD2vhpELRv//DwA)
[Try it tripled!](https://tio.run/##S8sszvj/39TMKD2vhpELnf7/HwA)
~~I'm sure there's an 8 byte solution somewhere out there.~~
The unprintable at the end has ASCII value 1, and is only fetched by the `g`et command on the third iteration. For the first two it prints `05`, and then prints `15`.
[Answer]
# [Labyrinth](https://github.com/m-ender/labyrinth), ~~12~~ ~~11~~ 9 bytes
```
:#%!@
 7
```
[TIO (1x)](https://tio.run/##y0lMqizKzCvJ@P/fQFlV0YFLwZzr/38A), [TIO (2x)](https://tio.run/##y0lMqizKzCvJ@P/fQFlV0YFLwZwLzvj/HwA), [TIO (3x)](https://tio.run/##y0lMqizKzCvJ@P/fQFlV0YFLwZwLk/H/PwA)
[Answer]
# JavaScript, ~~81 77 74~~ 70 bytes
Saved 4 bytes thanks to [Shaggy](https://codegolf.stackexchange.com/users/58974/shaggy)
```
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(alert,9,a)
```
Pretty lame JS solution. Consumes the values from the `[3,1,1]` array from the right (`pop()`). Registers a timeout to display the current value in the future. If a timeout was already registered, cancel it.
Relies on the dirty nature of `var`, which hoists variable declarations.
## Two times:
```
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(alert,9,a)
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(alert,9,a)
```
## Three times:
```
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(alert,9,a)
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(alert,9,a)
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(alert,9,a)
```
[Answer]
# [Lost](https://github.com/Wheatwizard/Lost), 27 bytes
```
\\<<<<//<<<>
2>((1+@>((%^
v
```
[Try it online!](https://tio.run/##y8kvLvn/PybGBgj09YGEHZeRnYaGobYDkFSN4yr7//@/biAA "Lost – Try It Online")
[Try it doubled!](https://tio.run/##y8kvLvn/PybGBgj09YGEHZeRnYaGobYDkFSN4yrDI/X//3/dQAA)
[Try it tripled!](https://tio.run/##y8kvLvn/PybGBgj09YGEHZeRnYaGobYDkFSN4yojT@r///@6gQA)
This is mostly an improvement of [Post Left Garf Hunter's answer](https://codegolf.stackexchange.com/a/158144/76162) that removes all the pesky no-ops from that last line,
To do this, we have to remove the `!`, otherwise the program always gets stuck in a loop. So we change the clearing section from `>?!^%^` to `>))%^`' since there can only be a max of two elements on the stack anyway. Unfortunately, this means that the path from the extra copies to the original is broken, so we place an extra `/` in the first line to compensate. This forces the pointer to go through the clearing section for all copies of the program until it reaches the first one, where the `^` instead redirects it to the `>` instead.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~53~~ 52 bytes
Note the space after `#endif`.
```
n;main(){putchar(n+49);}
#if __LINE__>7
n=2;
#endif 
```
[Try it online!](https://tio.run/##S9ZNT07@/z/POjcxM09Ds7qgtCQ5I7FII0/bxFLTupZLOTNNIT7ex9PPNT7ezpwrz9bImks5NS8FKPz/PwA "C (gcc) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 12 bytes
```
⎚≔⁺ι¹ιＩ⁻ι⁼ι²
```
[Try it online!](https://tio.run/##HYoxDoAgDAC/wlgSGHR1MsSdxBdUYpSkwdiC36/ojXeXTuR0IakG2pHBTmYWyUeBSE0gOzNYZ3LXkXOpEFAqrG2rjKl@ebkb0j@OtjOpqn/Ue6EX "Charcoal – Try It Online") Link is to verbose code.
[Try it doubled!](https://tio.run/##S85ILErOT8z5/985JzWxSEPTWsGxuDgzPU8jIKe0WCNTR8FQU0chEygcUJSZV6LhnFhcohFcmlRSlJhcApJ2LSxNzAErNNIEAmsFKpnz//9/3bL/urrFOQA)
[Try it tripled!](https://tio.run/##S85ILErOT8z5/985JzWxSEPTWsGxuDgzPU8jIKe0WCNTR8FQU0chEygcUJSZV6LhnFhcohFcmlRSlJhcApJ2LSxNzAErNNIEAmuFQWbO////dcv@6@oW5wAA)
### Explanation
```
⎚             Clear
 ≔⁺ι¹ι        Assign plus(i, 1) to i
       Ｉ      Cast (and implicitly print)
         ⁻ ⁼ι² Subtract equals(i, 2) from
          ι    i
```
[Answer]
# JavaScript, ~~43~~ 40 Bytes
```
var t=t?--t:~!setTimeout`t=alert(1|~t)`;
```
2x:
```
var t=t?--t:~!setTimeout`t=alert(1|~t)`;var t=t?--t:~!setTimeout`t=alert(1|~t)`;
```
3x:
```
var t=t?--t:~!setTimeout`t=alert(1|~t)`;var t=t?--t:~!setTimeout`t=alert(1|~t)`;var t=t?--t:~!setTimeout`t=alert(1|~t)`;
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~54~~ ~~48~~ ~~45~~ 44 bytes
```
if(99-gt(gc $PSCOMMANDPATH|wc -c)){1;exit}3#
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/PzNNw9JSN71EIz1ZQSUg2Nnf19fRzyXAMcSjpjxZQTdZU7Pa0Dq1IrOk1lj5/38A "PowerShell – Try It Online")
[Try it doubled!](https://tio.run/##K8gvTy0qzkjNyfn/PzNNw9JSN71EIz1ZQSUg2Nnf19fRzyXAMcSjpjxZQTdZU7Pa0Dq1IrOk1liZFLX//wMA "PowerShell – Try It Online")
[Try it tripled!](https://tio.run/##K8gvTy0qzkjNyfn/PzNNw9JSN71EIz1ZQSUg2Nnf19fRzyXAMcSjpjxZQTdZU7Pa0Dq1IrOk1liZVmr//wcA "PowerShell – Try It Online")
Gets its own invocation path with `$PSCOMMANDPATH` and performs a `g`et-`c`ontent on the file. `If` the character count of that file is less than `99` (checked via `wc -c` from coreutils), then we output `1` and `exit` (i.e., stop execution). That accounts for the original code and the doubled code. Otherwise we output `3` and exit. The actual code that's in the doubled or tripled sections is meaningless, since either we'll `exit` before we get to it, or it's behind a comment `#`.
*Saved 6 bytes thanks to Mr. Xcoder*  
*Saved ~~3~~ 4 bytes thanks to Pavel*
[Answer]
## C# (178 Bytes)
```
Console.WriteLine(1+2*4%int.Parse(System.Configuration.ConfigurationManager.AppSettings["z"]=(int.Parse(System.Configuration.ConfigurationManager.AppSettings["z"]??"0"))+1+""));
```
crazy C# solution, but I am happy it's possible in one line in C# at all. :) 
For me the hardest part was having valid C# that would either intialize or increment the same variable, so I ended up abusing the ConfigurationManager because I needed a global static NameValueCollection and ConfigurationManager was the only one I could think of that I could update in memory. EnvironmentVariables was another option I Iooked at but it doesn't have an indexer so I am not sure how to do that in one line that can be copy pasted to produce the required output as per the spec.
[Answer]
# [Runic Enchantments](https://github.com/Draco18s/RunicEnchantments/tree/Console), 35 bytes
```
^w3'\
    f
    1
/1@
/
 '54\w
/yyy
```
[Try it online!](https://tio.run/##KyrNy0z@/z@u3Fg9hksBCNLApCGXvqEDlz6XgrqpSUw5l35lZeX//wA "Runic Enchantments – Try It Online")
Working on this one allowed me to find an error in my parser dealing with the new delay modifier characters, although the final result ends up not being affected by it, as I ended up not needing them.
Functions due to the fact that the final line does not have a trailing newline (or for that matter, trailing spaces), allowing the duplicate IPs to spawn in a different place. The top-left one ends up making a large loop around the grid while the second IP performs a Reflection operation to replace the `\` on the 6th line with a . This IP then will loop forever and do nothing.
The third IP also makes this same replacement at the same time, but because it's situated on the *13th* line, its copy of that reflector sends it upwards and it executes the `1f'3w` sequence present in the upper right corner, which replaces the `1` with a `3` on the 14th line, just before the original IP executes it, causing the tripled program to output `3` instead of `1` (values could also be `2` and `6`, `3` and `9`, `4` and `12`, or `5` and `15` due to the availability of `a-f` numerical constants; `1` and `3` were chosen arbitrarily). It is then left in an endless loop performing more reflection commands that do nothing.
[Try it in triplicate!](https://tio.run/##KyrNy0z@/z@u3Fg9hksBCNLApCGXvqEDlz6XgrqpSUw5l35lZSV1lPz/DwA "Runic Enchantments – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~31~~ 25 bytes
```
p [*DATA][3]?3:1
__END__
```
[Try it online!](https://tio.run/##KypNqvz/v0AhWsvFMcQxNto41t7YypArPt7VzyU@nuv/fwA "Ruby – Try It Online")
[Try it online!Try it online!](https://tio.run/##KypNqvz/v0AhWsvFMcQxNto41t7YypArPt7VzyU@ngunxP//AA "Ruby – Try It Online")
[Try it online!Try it online!Try it online!](https://tio.run/##KypNqvz/v0AhWsvFMcQxNto41t7YypArPt7VzyU@not0if//AQ "Ruby – Try It Online")
### Explanation:
`__END__` is not part of the code and everything that follows it is returned by the iterator `DATA` as lines of text, simply count those lines and check if there are enough of them to switch from 1 to 3.
]