[Question]
  [
Making a [versatile integer printer](https://codegolf.stackexchange.com/questions/65641/the-versatile-integer-printer) is nice and all, but writing a single code that prints a lot of different numbers is cumbersome. Wouldn't it be easier to make a script that outputs a number, but also gives you a new script to get the next number?
**Challenge:**
Write a code that outputs a single integer `N` and an executable code. The next code should output `N+1` and a code that can output `N+2`. Continue this path until you reach `N = 15`. (The last printed number should be 15).
**Rules:**
* No input (assume the input is empty).
* Full program or function or other convenient formats are allowed.
* The first code should output `1`.
* You can't output leading zeros. I.e. you can't print `01` for `1`.
* The output must be on the format `N, Code_for_N+1`. Note that the output is separated by a comma and a single space. The code for `N+1` has no surrounding quotation marks. `N , Code_for_N+1` is not accepted (space in front of the comma). Trailing newlines are OK.
* The first character(s) of the output must be the number. (No leading spaces, or `ans = N`).
* The printed number should not be part of the next code (the code can contain this number, but you can't take the output number as part of the code)
	+ Example: The output for `N=2` can be: `2, printer 2`. In this case, `printer 2` is the code for `N=3`. You can't use the entire output: `2, printer 2` as code for `N=3`.
* The scripts may be in different languages
* The datatypes are irrelevant (the number can be a string), but it can't be surrounded by anything (quotation marks, parentheses etc).
* If there is a code outputted for `N=15` then it must either print `STOP!` (see bonus), or don't print anything at all (not even a space or newline).
	+ The code for `N=15` can not crash (but outputting to STDERR is OK).
	+ You are disqualified if the output code for `N=15` prints `16` or anything else (except the bonus case).
* Built in quine operators are not allowed.
* Accessing the source file through the file system is not allowed.
**Bonus:**
-10 bytes if the code that prints 15 also produces a code that prints "`STOP!`"
**Examples using Python syntax:** (obviously, these will only work for the selected integers, not from 1 to 15.)
```
N = 1
print "1, print 2"
1, print 2
---
N = 15
print 15
15
---
N = 15   (Qualifies for the -10 bytes bonus)
print "15, print 'STOP!'"
15, print 'STOP!'
print 'STOP!'
STOP!
----
N = 15   (Qualifies for the -10 bytes bonus)
print "15, disp('STOP!')"
15, disp('STOP!')        (disp('STOP!') outputs STOP! in MATLAB)
----
N = 15   (This one is not OK. The submission is disqualified)
print "15, print 16"
15, print 16
```
Standard golfing rules apply! Smallest code (for N=1) in bytes win!
  
[Answer]
## Pyth + ///, 15 bytes - 10 = 5
```
pPt`S15", STOP!
```
This prints `1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, STOP!` in Pyth, by taking `range(1,15+1)` and stripping off the start and end brackets, and printing it immediately followed by ", STOP!".
The next fourteen programs are in ///, which directly outputs all programs that don't contain `/` or `\`. So the second program
```
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
```
gives `2` and the third program `3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15`. The penultimate program, `15, STOP!`, prints `15, STOP!`, so the last program is just `STOP!`.
[Answer]
# JavaScript, 131238 - 10 = 131228 bytes
The naive approach turned out worse than expected. In hindsight I should have expected it. But I thought I'd share it anyway. Full code [here.](http://pastebin.com/raw/5nrCwPL1)
Idea: Iteratively escaping and adding the `N-1, ...`
```
alert("14,alert(\"15, alert(\\\"STOP!\\\")\")")
```
[Answer]
## CJam, ~~26~~ ~~25~~ 24 bytes
```
1{", "2$)@"_~"](_F<@*}_~
```
[Try it online.](http://cjam.aditsu.net/#code=1%7B%22%2C%20%222%24)%40%22_~%22%5D(_F%3C%40*%7D_~)
The subsequent programs simply have the first number incremented. [This runs the program 16 times.](http://cjam.aditsu.net/#code=q%0A%7B~%5Ds_oNoS%2F1%3ES*%7D16*&input=1%7B%22%2C%20%222%24)%40%22_~%22%5D(_F%3C%40*%7D_~)
---
Or with bonus for the same score:
```
1{", "\2$)_G<\@`+"_~"+"STOP!"`?}_~
```
[Try it online.](http://cjam.aditsu.net/#code=1%7B%22%2C%20%22%5C2%24)_G%3C%5C%40%60%2B%22_~%22%2B%22STOP!%22%60%3F%7D_~)
The subsequent programs simply have the first number incremented. [This runs the program 16 times.](http://cjam.aditsu.net/#code=q%0A%7B~%5Ds_oNoS%2F1%3ES*%7D16*&input=1%7B%22%2C%20%22%5C2%24)_G%3C%5C%40%60%2B%22_~%22%2B%22STOP!%22%60%3F%7D_~)
Alternative solution for the bonus:
```
1{", "\2$)Gmd@`+"_~"+"STOP!"`\?}_~
```
[Answer]
# JavaScript (ES6), ~~62~~ 61 bytes - 10 bonus = 51 score
```
_=>"1, "+(f=n=>`_=>"`+(n<16?n+`, "+(${f(n+1)})`:`STOP!"`))(2)
```
## Explanation
A solution which does not read it's own source code and is also not ridiculously long.
The first program constructs all 15 other programs and nests them inside each other using a recursive function. I get around the backslash issue by nesting the functions themselves (which are then cast to strings during output) rather than strings.
```
_=>
  "1, "                // print the first number
  +(f=n=>`_=>"`+(      // f = recursive function for printing program N
    n<16?              // for programs 2 - 15:
      n+`, "+(${       // add N to the output of the nested function
        f(n+1)         // nest the code of program N + 1
      })`
    :`STOP!"`          // program 16 just outputs "STOP!" for the bonus
  ))(2)                // start from program 2
```
## Test
```
var nextProgram = '_=>"1, "+(f=n=>`_=>"`+(n<16?n+`, "+(${f(n+1)})`:`STOP!"`))(2)',
    n = 1;
while(nextProgram) {
  result.textContent += "Program " + n++ + ": " + nextProgram + "\n";
  var output = eval("(" + nextProgram + ")()");
  result.textContent += "   Output: " + output + "\n\n";
  var index = output.indexOf(",");
  nextProgram = index > 0 ? output.substr(index + 2) : null;
}
```
```
<pre id="result"></pre>
```
[Answer]
# Matlab, ~~226~~ 212 - 10 = 202 bytes
Thanks to @StewieGriffin for a few bytes=)
```
'awFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
```
The first part is a string that represents the second line (below), the actual code (just shifted by 9). In Matlab, strings are matrices filled with characters, so you can easily perform the shifts by just adding/substracting a scalar. So the program just prints out the same string\* again, plus the same string but shifted which results in the code.
\*Not quite: The first byte is the counter which needs to be increased in each iteration.
The quine trick with the string was shamelessly stolen from [here.](http://blog.garritys.org/2009/10/quines.html)
```
'awFjw|Dro)w1:26B?G:>DwF0\}xy*0Dnu|nDwFdw~v;|}{1w1:26B?2505)05<B5w1:24:5w1;Cnwm25<B5>B5w1;Cnwm26B500fDnwmDmr|y1w2';
n=ans;if n(1)-96>15;n='Stop!';else;n=[num2str(n(1)-96),', ',39,n(1)+1,n(2:end),39,59,n(2:end)-9,''];end;disp(n)
```
Here the last few lines of the sequence copied from the console:
```
>> 'mwFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
13, 'nwFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
>> 'nwFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
14, 'owFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
>> 'owFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
15, 'pwFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
>> 'pwFjw|DWFw1:2DVFw1;Cnwm2Dro)WG:::DwF0\]XY*0Dnu|nDwFdw~v;|}{1W6B?2505)05<B5W4:5V5<B5>B5V6B500fDnwmDmr|y1w2';n=ans;N=n(1);M=n(2:end);if N>111;n='STOP!';else;n=[num2str(N-96),', ',39,N+1,M,39,59,M-9,''];end;disp(n)
STOP!
```
[Answer]
## JavaScript, ~~50~~ ~~47~~ ~~44~~ ~~42~~ 44\* bytes
```
a=_=>(x=1)+(x<15?", a="+a:"").replace(x,x+1)
```
It's a function which extracts its own body (just `a`) and makes replacements in it. Getting the function body a built-in feature of JavaScript, though not being explicitly a quine operator (if it's invalid, will remove the answer).
```
a=_=>(x=1)+(x<15?", a="+a:"").replace(x,x+1);
alert(a());
```
In case it doesn't work properly embedded there (because for me it doesn't), you can see an example [there](http://www.es6fiddle.net/ij4kgl7v/).
---
\* - looks like the snippet produces the result without `a=`, making further calls impossible
[Answer]
# Python 2.7.10, ~~196~~ 92 - 10 = 82 bytes
Whee!!! This was fun. Much shorter now. :P
```
n=1;a='n=%d;a=%r;print n,a%%(n+1,a)if n!=15else"STOP!"';print n,a%(n+1,a)if n!=15else"STOP!"
```
---
### Explanation:
I started with this:
```
a='a=%r;print a%%a';print a%a
```
That is just a simple quine.
This is that with a counter added:
```
n=1;a='n=%d;a=%r;print n,a%%(n+1,a)';print n,a%(n+1,a)
```
`n` is a counter variable that is printed at the beginning. Then when its prints the `n=` part, it substitutes `n+1` for the `%d`. So from here it will count up infinitely.
And here is the final version. It adds an if clause to stop at 15, and prints "STOP!" as well.
```
n=1;a='n=%d;a=%r;print n,a%%(n+1,a)if n!=15else"STOP!"';print n,a%(n+1,a)if n!=15else"STOP!"
```
Old code:
```
a= ['if num==15:print"STOP!!!";exit()','print num','print"a=",a','print"num=",num+1', 'for s in a:print s']
num= 1
print num
if num==15:print"STOP!!!";exit()
print"a=",a
print"num=",num+1
for s in a:print s
```
~~Never going to win, but fun. :P~~ Much shorter now, though I still don't stand a chance. :P
[Answer]
## PowerShell, ~~(215-10)=205~~ ~~197~~ ~~167~~ ~~106~~ ~~104~~ 103 bytes
```
$d='$c=(,1*{2}).count;$d={0}{1}{0};(("$c, $d"-f[char]39,$d,($c+1)),$c)[$c-eq15]';"1, $d"-f[char]39,$d,2
```
(If your only tool is PowerShell, every problem looks like a nail. Wait...)
Essentially, we start with setting `$d` equal to a big-ole-lengthy string of an almost-[quine](https://codegolf.stackexchange.com/a/57648/42963) of the original code. It outputs `1` and then `$d` with the format operator `-f` to correctly populate the `{0}`,`{1}`,`{2}` stand-ins, incrementing the `{2}` number in the `,1*{2}` section by one each time.
The `,x*y` operation in PowerShell creates a new array of `y` items, each of which is equal to `x`. For example, `,2*3` is equivalent to `@(2,2,2)`.
This means, the first output will be `1, $c=(,1*2).length;$d=(etc...)`, so when the second code is executed, `$c` will equal the count of the array `@(1,1)`, or `2`, etc. Note that `$c` isn't used as a variable in the original code, just in subsequent runs.
Stops when it prints 15 by simply calculating whether `$c` equals `15` and then indexing into an array, the 0th element is `$c, $d` as described above, the other is just `15`. Thus, when `$c` is 15, it'll output `15` and nothing else. Doesn't qualify for the bonus, because `"15, {0}STOP!{0}"` is 5 characters too long for the -10 to be worthwhile.
Requires a PowerShell terminal of width > ~150. Or for you to manually remove the extra linebreak (that the terminal *helpfully* inserts on output wrap) when copy-pasting the code. Or for you to capture output into a variable and then re-execute that variable. Etc.
Edit 1 -- Saved some bytes by removing the "STOP!" wording.  
Edit 2 -- Durr, don't use .length each time, just call it once  
Edit 3 -- Doesn't need to be a quine, so the initial run can be a lot shorter  
Edit 4 -- Changed from using strings to arrays to calculate `$c`, which saved two bytes. I'm pretty sure this is almost optimal for this approach.  
Edit 5 -- Saved another byte by directly counting equality rather than modding
[Answer]
## JavaScript, 79 - 10 = 69 bytes
```
s='STOP!';for(i=15;i;){s=i--+',alert("'+s.replace(/[\\"]/g,"\\$&")+'")'};alert(s)
```
Without using `Function.prototype.toString` in any way at all.
[Answer]
# Befunge, 57 - 10 = 47 bytes
```
1:'!`'#*j:.',,1+:9`''*'0++,1#;:0g:48*`j@,1+;"!POTS",,,,,@
```
This one is awesome. Try it [here](http://befungius.aurlien.net).
[Answer]
## Batch, 73 + 5 - 10 = 68 bytes
```
@set a=STOP!
@for /l %%a in (15,-1,1)do @set a=%%a, @echo !a!
@echo %a%
```
Requires `CMD /V:ON` so I added 5 bytes for that.
[Answer]
## Python 2.7, 107 characters
By using recursion and *not* writing a quine, I thought I could save a lot, which is true, but not good enough. Although not a winner, I think the approach is fun to share.
I started by making up a string for N=4, escaping the `\` and `"` characters.
```
print "1, print \"2, print \\\"3, print \\\\\\\"4, print \\\\\\\\\\\\\\\"STOP!\\\\\\\\\\\\\\\"\\\\\\\"\\\"\""
```
Then I created a lambda function that creates this string, based on a start index and a stop index, using recursion. This is it:
```
l=lambda n,m:str(n)+", print "+"\\"*(2**(n-1)-1)+"\""+l(n+1,m)+"\\"*(2**(n-1)-1)+"\"" if n<m else "STOP!"
```
Use it like this:
```
print l(1,15)
```
Output: *[32902 characters, too long to handle]*
So, it seems that my kolmogorov complexity approach isn't that successful ;-)
[Answer]
## [SMBF](https://esolangs.org/wiki/Self-modifying_Brainfuck), 28 bytes
`\x10` represents a literal byte (decimal value 16). The integer is output as an integer (byte). So the first *character* output is `\x01`. The program then prints ", ". When printing its own source, it prints an extra `+` at the beginning.
```
+.<-<<.>.>[[<]>.[.>]<[-]], \x10
```
Explanation:
```
+.                                  Increment number and print
  <-                                Pre-decrement loop counter
    <<.>.>                          Print comma and space from own source
          [             ]           Only execute if loop counter != 0
           [<]>.                    Move to left of source, then print `+`
                [.>]                Print entire source.
                    <[-]            Zero out the loop counter so this program halts.
                         , \x10     The comma, space, and loop counter used earlier.
                                    Input is empty, so `,` doesn't do anything.
```
Note that you cannot run this in a standard interpreter because it requires a hex literal in the input. You also need a special terminal for hex output to work properly.
[Answer]
# Bash, ~~78~~ ~~74~~ 73 - 10 = 63 bytes (Example, can't win)
```
p='if(($((++a>15))));then unset a p;fi;echo ${a-STOP\!}${p+, $p}';eval $p
```
Coming in late, but saw bash hadn't been tried so gave it a go. First gulf challenge and quine-like puzzle. They're fun!
### Explanation:
This works because `a` steps from 1 to 15 and is then `unset` along with `p`. The script (stored in `p`) prints them both out if they're `set` and "STOP!" otherwise. The initially `unset` `a` is `set` to 0 because it appears in an arithmetic expansion.
[Answer]
# ùîºùïäùïÑùïöùïü, 30 chars / 47 bytes (non-competitive)
```
‚üÆa=1)+(a<·∏è?‚¨¨+‚í∏‚Ö©222+·∂à0:‚¨Ø)ƒì(a,‚ß∫a
```
`[Try it here (Firefox only).](http://molarmanful.github.io/ESMin/interpreter2.html?eval=false&input=&code=a%3D1%29%2B%28a%3C%E1%B8%8F%3F%E2%AC%AC%2B%E2%84%B9%29%3A%E2%AC%AF%29%C4%93%28a%2C%E2%A7%BAa)`
Finally found a good ol' true quine for ùîºùïäùïÑùïöùïü.
# Explanation
Here's the true quine that I used: `‚üÆ‚í∏‚Ö©222+·∂à0`
You see it in my answer? Hopefully, y'all will be able to expand from there.
[Answer]
## [Keg](https://esolangs.org/wiki/Keg)+PHP, 19-10=10 bytes
```
√Ø_(. \,,,)\!POTS(,
```
Counts from 1 to 15 and then stops. [TIO](https://tio.run/##y05N//@f//D6eA09hRgdHR3NGMUA/5BgDZ3//wE)
## Keg, 13 bytes
```
√Ø_(. \,,,).
```
[Answer]
# [Python 2](https://docs.python.org/2/), 68 (-10) bytes, [Python 3](https://docs.python.org/3/), 69 (-10) bytes
My previous answers were incorrect. That's now fixed :)
## Python 2 (68 bytes, 58 points)
```
a,b="print'%d, a,b=%r,%d;exec a'%(b,a,b+1)*(b<16)or'STOP!'",1;exec a
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P1EnyVapoCgzr0RdNUVHAcRVLdJRTbFOrUhNVkhUV9VI0gEKahtqamkk2RiaaeYXqQeH@AcoqivpGEIVcVFiiBE1DDGmhiEmMEPA@pX09PSUKDLP0JQarjI0g6r6/x8A "Python 2 ‚Äì Try It Online")
## Python 3 (69 bytes, 59 points)
```
a,b="print(f'{b}, a,b=%r,{b+1};exec(a)'%a*(b<16)or'STOP!')",1;exec(a)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P1EnyVapoCgzr0QjTb06qVZHASSiWqRTnaRtWGudWpGarJGoqa6aqKWRZGNopplfpB4c4h@gqK6ppGMIk@aixBQjqphiTBVTTOCmQAxQ0tPTU6LMSENTqrjM0Awm//8/AA "Python 3 ‚Äì Try It Online")
## How it works:
* I started from the quine `a="print("a=%r;exec(a)"%a);exec(a)"`
* I assign `b` to the value to be printed
* Then I print `b,`  and the quine replacing `b` by `b+1`
* If `b` is equal to `16`, I print `STOP!` intead
]