Euler’s Totient Function
You are given an integer 'N'. Your task is to count the number of integers between 1 and 'N' both inclusive which are coprime to 'N'.
Note:
Two numbers are coprime if their greatest common divisor(GCD) is 1.
Here, 1 is considered to be coprime to any number.
For Example:
If the given integer is 9, then the answer would be 6 Because there are six numbers between 1 and 9 both inclusive which are coprime to 9 i.e 1, 2, 4, 5, 7, and 8.
Input Format:
The first line of input contains an integer 'T' representing the number of test cases or queries to be processed.
Then the test case follows.
The only line of each test case contains an integer 'N'.
Output Format:
For each test case, print a single line containing a single integer denoting the total numbers of integers between 1 and 'N'(both inclusive) which are coprime to 'N', in a single line.
The output of each test case will be printed in a separate line.
Note:
You don't have to print anything. It has already been taken care of. Just implement the function.
Constraints:
1 <= T <= 100
1 <= N <= 10 ^ 9
Time Limit: 1 sec.
Be the first one to answer
Add answer anonymously...
Top Amadeus Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Amadeus Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app