Coprime Graph
Time limit1sMemory limit512 MB
Count pairs (a, b) with 1 <= a < b <= N whose greatest common divisor is 1.
- Level
Medium4 of 10
- Topics
- Math, Number theory, Combinatorics, Prefix sum
- Solved
- No attempts yet
Problem
Wooshik draws a graph whenever he is bored. He draws a new graph every month, and this month he is drawing a coprime graph.
The coprime graph has vertices numbered through . Two distinct vertices are directly connected by an edge only when their numbers are coprime.
Wooshik is curious how many edges he has to draw. Given the number of vertices , find the number of edges he must draw.
Input
The first line gives the number of vertices of the graph.
Output
Print the number of edges Wooshik has to draw.