Count Coprimes
Two numbers are coprime when their greatest common divisor is 1. Return how many integers from 1 to n (inclusive) are coprime with n.
Example 1
n 10
returns 4
1, 3, 7 and 9.
Example 2
n 1
returns 1
gcd(1, 1) = 1.
Constraints
1 <= n <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.