Chaining Programs

Pyth, 12

p1:

l"1

p2: 1

p3: 1

etc..

p1p2p3:

l"111 

Output: 3

Explanation:

l        length
 "1      string "1"

On first run, this outputs the length of a single character string, 1. This also happens to be a valid Pyth program, outputting 1 again. Therefore, pn+1 is always 1. When the programs are chained, p1 outputs the length of the chained programs, which will be n.


Lua, 950 900 bytes

s=io.open(arg[0]):read()if#s<95 then print(s)do return end end print(#s/90) do return end;

Ungolfed:

s=io.open(arg[0]):read'*a'
if #s < 96 then 
    print(s)
    do return end 
end 
print(#s/90) 
do return end;

Explanation:

The first line grabs the entire source of the program. Then we compare the length of the entire program to 1 + the length of one single program. If the size of the current program is smaller than this value, than the source is printed, which is the next program, p2, and we exit. Each iteration is just a quine. When several of these are put together, the the conditional fails, and we print the length of the concatenated program divided by the length of one program, which is the number of concatenated programs, n.


Vitsy, 14 bytes

Similar to the Pyth and Jolf answers, I'm mapping strings. The only difference is that I use the line wrapping features to make sure I always get the right length.

p1

'l3-N

p2

1

Replace 1 with any single number.

p3 and so on match this pattern, and you can do this until Integer.MAX_VALUE, the integer restriction of the language.

Explanation:

'l3-N
'     Wrap around the line until finding another '. Since no ' is found before the
      End of the line, it wraps around.
 l    Get the length of the stack.
  3-  Subtract three.
    N Output as number.

Try it online!