Count of integers
Practice
3.7 (19 votes)
Algorithms
Euler's totient function
Greatest common divisor
Math
Number theory
Sieve
Problem
84% Success 6701 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a positive integer \(n\), for \(Q\) queries, You are required to determine the number of integers \(k\) (\(1 \leq k \leq n\)) such that \(gcd(k,n)\hspace{2mm}!= 1\) and \(gcd(k,n)\hspace{2mm}!= k\).

Input format

  • First line: Integer \(Q\) denoting the number of queries
  • Next \(Q\) lines: Integer \(n\)

Output format

Print \(Q\) lines each containing an integer that denotes the answer to that specific query.

Constraints

\(1 \leq Q \leq 10^5\)

\(1 \leq n \leq 10^6\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
12 votes
Tags:
EasyMathNumber TheoryNumber theory
Points:30
59 votes
Tags:
ApprovedEasyMathNumber TheoryOpen
Points:30
10 votes
Tags:
AlgorithmsMathNumber TheoryNumber theory