[Question]
  [
A *1-up quine* is a program which is very similar to a quine. The one major difference is that instead of printing itself once, when **n** copies of the program are concatenated, the result prints the original program **n+1** times.
## Example
If your program is `Abc123`:
```
Abc123  ->  Abc123Abc123
Abc123Abc123  ->  Abc123Abc123Abc123
Abc123Abc123Abc123  -> Abc123Abc123Abc123Abc123
```
# Challenge
Your challenge is to create the shortest valid 1-up quine in any language. The usual quine rules apply, so you may not:
* Submit the empty program.
* Directly or indirectly read1 the source code.
* Use quining built-ins.
This is code-golf, so **shortest code in bytes wins.**
1This does not include using a hard-coded string or code block as part of your program.
  
[Answer]
# GolfScript, 12 bytes
```
{: ".~"][}.~
```
[Try it online!](http://golfscript.tryitonline.net/#code=ezogIi5-Il1bfS5-&input=)
### How the source code works
```
{: ".~"][}.~
{        }    Define and push a code block.
          .~  Push a copy and execute it.
 :            Save the code block in the space character.
              Every subsequent space will now execute the code block.
   ".~"       Push that string.
       ]      Wrap everything up to the last [ in an array.
        [     Set a new array marker.
```
If the above source code is executed once, the stack will end up as
```
["" {: ".~"]} ".~"]
```
where the empty string at the beginning corresponds to the initial state of the stack (empty input).
Two copies of the source code would leave a final state of
```
["" {: ".~"]} ".~"] [{: ".~"]} ".~"]
```
three copies a final state of
```
["" {: ".~"]} ".~"] [{: ".~"]} ".~"] [{: ".~"]} ".~"]
```
and so on.
### What happens next
After executing the source code, the interpreter does the following.
1. It wraps the entire stack in an array, and pushes that array on the stack.
For two copies of the source code, the stack now contains
```
["" {: ".~"][} ".~"] [{: ".~"][} ".~"] [["" {: ".~"][} ".~"] [{: ".~"][} ".~"]]
```
2. It executed `puts` with the intention of printing the wrapped stack, followed by a linefeed.
`puts` is defined as `{print n print}`, so it does the following.
	1. `print` prints the wrapped up copy of the stack without inspecting it (i.e., without converting it to its string representation). This sends
	
	
	
	```
	{: ".~"][}.~{: ".~"][}.~
	
	```
	
	(the source code) to STDOUT and pops the stack copy from the top of the stack.
	
	
	The stack now contains
	
	
	
	```
	["" {: ".~"][} ".~"] [{: ".~"][} ".~"]
	
	```
	2. executes the code block we defined previously.
	
	
	`:` begins by saving `[{: ".~"][} ".~"]` in the space character, then `".~"` pushes itself, `]` wraps the `".~"` in an array, and `[` sets a new array marker.
	3. `n` pushes a string consisting of a single linefeed.
	
	
	The stack now contains
	
	
	
	```
	["" {: ".~"][} ".~"] [{: ".~"][} ".~"] [".~"] "\n"
	
	```
	4. is executed once more. However, it was redefined when we called it for the first time and now contains an array, not a code block.
	
	
	In fact, it pushes `[{: ".~"][} ".~"]`, leaving the stack as
	
	
	
	```
	["" {: ".~"][} ".~"] [{: ".~"][} ".~"] [".~"] "\n" [{: ".~"][} ".~"]
	
	```
	5. Finally, `print` prints the topmost stack item without inspecting it, sending
	
	
	
	```
	{: ".~"][}.~
	
	```
	
	to STDOUT, 1-upping the source code.
[Answer]
## GolfScript, 12 bytes
```
{`'.~'+:n}.~
```
[Try it online!](http://golfscript.tryitonline.net/#code=e2AnLn4nKzpufS5-&input=)
### Explanation
This combines ideas from the standard GolfScript quine:
```
{'.~'}.~
```
And my [recently discovered quine](https://codegolf.stackexchange.com/a/71488/8478):
```
":n`":n`
```
The main idea is again to use `n` which is printed implicitly at the end of the program in order to get the additional copy of the quine. Since assigning the variable doesn't change anything when it's done again in subsequent copies, this will only add one copy. Here's a breakdown of the code:
```
{        # Standard quine framework. This pushes the block, duplicates it and runs the
         # second copy, such that it can process the first copy to create a quine.
  `      # Convert the block to its string representation.
  '.~'+  # Append the string '.~' to make a complete quine. This is simply left on the
         # stack to be printed at the end.
  :n     # Store the string in n such that one more copy is printed at the end.
}.~
```
[Answer]
# Javascript ES6 (REPL), 55 bytes
```
var a=-~a;$=_=>`var a=-~a;$=${$};$();`.repeat(a+1);$();
```
*Saved 2 bytes thanks to @user81655!*
# Explanation
Here's the standard quine framework:
```
$=_=>`$=${$};$()`;$()
```
You should be able to see this framework inside the submission. More explanation below.
---
```
var a=-~a;
```
This is the counter, defaulted to 1. Basically, it tells us how much to repeat the quine and increments at the same time.
```
$=_=>`var a=-~a;$=${$};$();`.repeat(a+1);$();
```
This is the quine part. We essentially repeat the quine string by the counter+1. Subsequent function calls will override the output.
[Answer]
# CJam, 14 bytes
```
{"_~"]-2>_o}_~
```
[Try it online!](http://cjam.tryitonline.net/#code=eyJffiJdLTI-X299X34&input=)
### How it works
```
{"_~"]-2>_o}_~
{          }    Define a code block and push it on the stack.
            _~  Push and execute a copy of it.
 "_~"           Push that string.
     ]          Wrap the entire stack in an array.
      -2>       Discard all but the last two elements (block and string).
         _o     Push and print a copy of that array.
```
After the last copy of the program has been executed, the array that contains the block and the string is still on the stack, so it is printed implicitly.
[Answer]
# Groovy, 83 bytes
```
s="s=%c%s%c;f={printf(s,34,s,34,10)};f()%cf()//";f={printf(s,34,s,34,10)};f()
f()//
```
There is one embedded and no trailing newline. This prints:
```
s="s=%c%s%c;f={printf(s,34,s,34,10)};f()%cf()//";f={printf(s,34,s,34,10)};f()
f()//s="s=%c%s%c;f={printf(s,34,s,34,10)};f()%cf()//";f={printf(s,34,s,34,10)};f()
f()//
```
The function `f()` prints one copy of the quine. The initial program calls it twice. The first line of the appended code becomes a comment and only the second call to `f()` is executed.
[Answer]
# Ruby, 43 bytes
```
1;s="1;s=%p;$><<s%%s*n=2-0";$><<s%s*n=2-0
```
By itself, this prints itself `2-0` or `2` times. When concatenated to another copy of itself, the final print statement looks like `$><<s%s*n=2-01`, meaning it outputs itself just once (`01` being octal 1). So only the final copy of the string prints twice, the others print once.
The inline assignment to `n` is just to get the order of operations working correctly; state isn't actually being passed from one copy to the next.
[Answer]
# NodeJS, ~~63~~ ~~61~~ ~~60~~ 55 bytes
*this will also work in JavaScript (ES6) if you consider multiple console messages to be separated by newlines (no REPL required)*
Saved 2 bytes thanks to @dev-null
```
(f=_=>(t=_=>console.log(`(f=${f})()`)||(_=>t))(t()))()
```
*note that there is a newline at the end of the code.*
  
This was an interesting one, definitely one of my favorites for this site so far.
I'm fairly confident this can't be golfed much more. *(maybe SpiderMonkey's `print` function...)* 
## Explanation
```
//FIRST ITERATION
            console.log(`(f=${f})()`)                   //logs to the console a quine of the source code using function f's toString()
                                     ||                 //causes the expression to evaluate to the second part, since console.log's return value is falsy
                                       (_=>t)           //a function that returns function t when called
       t=_=>                                            //defines function t to be the code above. When called, t will log a quine and then return a function that returns t.
      (                                      )(t())     //call t twice. (one call is done via the t() as an ignored parameter) This will print the quine twice.
 f=_=>                                                  //define f as the above code.
(                                                  )()  //call function f with no arguments. this results in a function returning t. (the result of calling t once)
                                                        //this newline is to compensate for console.log's behavior of adding a newline to its output
//SECOND ITERATION
(                                                  )    //call the function that returns t that was returned from the first iteration. This expression will result in whatever that function returns, which is t.
 f=_=>(t=_=>console.log(`(f=${f})()`)||(_=>t))(t())     //this part evaluates to a function, which is passed as a parameter to the function that returns t, that ignores its parameter.
                                                    ()  //call whatever the last expression returned, which is the function t, with no parameters. This will print the quine once.
                                                        //this call will result in a function returning t, just like from the first iteration, so we can add on more iterations at will.
```
[Answer]
## Ruby, 55 bytes
```
n||=2;s="n||=2;s=%p;$><<(s%%s)*n;n=1;";$><<(s%s)*n;n=1;
```
Nothing very interesting here, it is just a normal ruby quine with a counter.
[Answer]
# JavaScript (ES6), 164 bytes
```
console.log((`+String.fromCharCode(96)).repeat(window.a||(a=3,5)).slice(67,-14))
console.log((`+String.fromCharCode(96)).repeat(window.a||(a=3,5)).slice(67,-14))
```
Works in any JS testing page or console in Firefox, assuming that the space between two console messages counts as a newline.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~58~~ 53 bytes
*Thanks to Jo King for -5 bytes.*
```
<say "<$_>~~.EVAL for 0..!.++;">~~.EVAL for 0..!.++;
```
Based on [Jo King's quine](https://codegolf.stackexchange.com/a/176322/14109).
[Try it online!](https://tio.run/##K0gtyjH7/9@mOLFSQclGJd6urk7PNczRRyEtv0jBQE9PUU9b21oJqyjX//8A "Perl 6 – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~65~~ ~~61~~ 55 bytes
```
a=2
exec(s:='print(end="a=2\\nexec(s:=%r)#"%s*a);a=1')#
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPr/P9HWiCu1IjVZo9jKVr2gKDOvRCM1L8VWCSgeE5MHk1Et0lRWUi3WStS0TrQ1VNdU/v8fAA "Python 3.8 (pre-release) – Try It Online")
---
# [Python 2](https://docs.python.org/2/), 60 bytes
```
s='try:n\nexcept:n="s=%r;exec s"%s;print n\nprint n';exec s
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v9hWvaSo0iovJi@1Ijm1oMQqz1ap2Fa1yDq1IjVZoVhJtdi6oCgzr0QBqALKUIfKcf3/DwA "Python 2 – Try It Online")
[Answer]
# Japt, 40 bytes
```
Oo("+Q ²pT°?1:2 é4;POo("+Q ²pT°?1:2 é4;P
```
[Test it online!](http://ethproductions.github.io/japt?v=master&code=T28oIitRILJwVLA/MToyIOk0O1BPbygiK1EgsnBUsD8xOjIg6TQ7UA==&input=) Explanation to come.
[Answer]
# [Y](https://github.com/ConorOBrien-Foxx/Y)
## Noncompeting, 6 bytes
```
UCn*px
```
Y is a headcannon that I've had for a while, and this inspired me to write it. It is made for challenges in which sequencing is key, such as this. The code is divided into links by "node" characters. In this case, our code is put into two chains (originally), with the node being `C`.
```
U  C  n* px
1  N    2
```
`U` records a transcendental string, i.e., one that spans links. It records until it meets another `U`. If a `U` is not met by the end of the string, it wraps around. Also, `U` is included in the string by default. After recording the string, we proceed to the node `C`, which just moves us to the next link.
`n` pushes the number of chains. For our base case, this 2. For a sequence of `K` chains, there are `K+2` chains, as there are `K` nodes. `*` is string repittion. `p` prints the entire stack (in this case, one string), and `x` terminates the program.
In a text:
```
UCn*px
U..... record that string
 C     next link
  n*   repeat that string twice.
    px print and terminate
UCn*pxUCn*pxUCn*px
U.....U            record string
 C                 next link
  n*               repeat that string four times (three Cs)
    px             print and terminate
```
[Try it here!](http://conorobrien-foxx.github.io/Y/)
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 20 bytes
```
⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1HX0kcdK5QgVF12elb5o6ZmIG5VQjD//wcA "Brachylog – Try It Online")
Modified from [this quine.](https://codegolf.stackexchange.com/a/183203/85334)
```
⊥                       Fail,
 ∨                      or
                w       print
  "⊥∨~kgjw₃w₅"          "⊥∨~kgjw₃w₅"
                 ₃      formatted
              gj        with itself;
                 ₃w₅    print it again at the end of the program if this route succeeds.
```
When this is concatenated with itself, every route except the last fails and the program moves on to the next one, executing each `w₃` and backtracking past every `w₅` except the very last one.
```
⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1HX0kcdK5QgVF12elb5o6ZmIG5VQjCJUfP/PwA "Brachylog – Try It Online")
```
⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1HX0kcdK5QgVF12elb5o6ZmIG5VQjCppeb/fwA "Brachylog – Try It Online")
```
⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅⊥∨"⊥∨~kgjw₃w₅"gjw₃w₅
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1HX0kcdK5QgVF12elb5o6ZmIG5VQjDpqeb/fwA "Brachylog – Try It Online")
]