Problem: farey

Problem IDfarey
Difficulty level (0..10)5
Maximum runtime2 minutes
Original problemfarey.ps

Write a program which outputs, for each given integer N, N greater or equal than 1, less or equal to 300, the ascending sequence of all reduced fractions from [0,1] having the denominator not greater than N. A fraction is reduced if its nominator and denominator are relatively primes. The input will be a series of integers N, one at a line. The output should be as in the example:

Sample input:

6
7

Sample output:

N=6
1/6
1/5
1/4
1/3
2/5
1/2
3/5
2/3
3/4
4/5
5/6
1/1
---
N=7
1/7
1/6
1/5
1/4
2/7
1/3
2/5
3/7
1/2
4/7
3/5
2/3
5/7
3/4
4/5
5/6
6/7
1/1
---