Complete Stars
Time limit2sMemory limit512 MB
For each N, count the values k with 1 <= k < N/2 whose step visits every marked point, i.e. gcd(k, N) = 1.
- Level
Medium4 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
Fernando got a compass for his birthday, and his favorite pastime now is drawing stars. He first marks points on a circle, splitting it into arcs of equal length. He then draws a segment from one point to the -th point clockwise from it, and keeps drawing segments the same way until he returns to the starting point.
Depending on , the drawing passes through every marked point or through only some of them. A star that passes through every point is called complete. For example, when the four stars below can be drawn. Stars (a) and (c) are complete, while stars (b) and (d) are not.

The step is chosen in the range , and and produce the same drawing, so they count as one star.
Given , write a program that determines how many complete stars Fernando can draw.
Input
The input consists of several test cases. Each line holds a single integer , the number of arcs the circle was split into. The input continues until end of file.
Constraints
Output
For each test case, print a single integer on its own line, the number of complete stars that can be drawn.