Quit Whining; Start Quining Goal:

Write a function or program that, given an integer n, will output a program in the same language that is a quine with a period of n.

Description of Output Program:

The output program needs to be a program that, when run, ... will output a program... that will output a program... etc, until the nth program is the original (first) output program. So this is, in a way, a modular quine. That's how I think of it, anyway.

The resulting programs should all be distinct.

Example:

Input: 2

Program: modulus_quine(n)

Output: P → Q → P → ...

Scoring:

This is code-golf, so shortest code (for the generating program) wins.

Brownie points (-0 bytes, +1 thumbs up?) are given to anyone whose generating program IS their modular quine. This is where your program takes the input and outputs the first modular quine in the sequence, which outputs the next, etc. The resulting output programs must not prompt the user for input (until it gets back to the generator.)
GolfScript, 16 bytes

{%}+")1$~":x`+0x


Try it online in Web GolfScript.

Example run

$ echo -n 3 | golfscript quining.gs      
{3 % ")1$~"}0)1$~
$ echo -n 3 | golfscript quining.gs | golfscript 
{3 % ")1$~"}1)1$~
$ echo -n 3 | golfscript quining.gs | golfscript | golfscript 
{3 % ")1$~"}2)1$~
$ echo -n 3 | golfscript quining.gs | golfscript | golfscript | golfscript 
{3 % ")1$~"}0)1$~


Generator

                 # (implicit) Read from STDIN.
{%}+             # Concatenate the read input with the block.
                 # For example, "3"{%}+ -&gt; {3 %}.
    ")1$~":x     # Push that string and save it in the the variable `x'.
            `+   # Inspect the string and concatenate it with the block.
                 # For example, {3 %}'")1$~"'+ -&gt; {3 % ")1$~"}
              0x # Push a 0 and the string stored in `x'.


Modular quine

For example, the modular quine {3 % ")1$~"}0)1$~ works as follows.

{          }      # Define a block.
 3 %              # Take the integer on the stack modulo 3.
     ")1$~"       # Push that string.
            0)    # Push 0 and increment. Pushes 1.
              1$~ # Copy the block from the bottom of the stack and execute it.


The original copy of the block, the modified integer and the string the block pushed are printed, resulting in {3 % ")1$~"}1)1$~.

All printed programs have a trailing linefeed, which GolfScript prints automatically.