Repeated Quine program A Quine is a computer program which produces a copy of its own source code as its only output. Is there any Quine program that could print itself out n times, with n specified some way in the program?
Fun question! As a base I will use this Haskell quine I found on Wikipedia:

main=putStr(p++show(p))where p="main=putStr(p++show(p))where p="


You can make it print out two copies of itself by replacing the occurrences of p++show(p) with p++show(p)++p++show(p). If you see why, the pattern to achieve variable repetition should be clear.

I will be using the following function that calculates the nth iterate of f on x:

iterateN n f x = (iterate f x) !! n


I'll assume it's available as a library function. You can easily embed its definition directly in the quine, but that would clutter the presentation without good reason. Now the rest is simple:

main=putStr(iterateN 42(++(p++show(p)))[])
  where p="main=putStr(iterateN 42(++(p++show(p)))[])where p="


The line break was inserted to aid readability; remove it if you want exact self-replication.