Sphere Online Judge

SPOJ Problem Set (classical)

4141. Euler Totient Function

Problem code: ETF

In number theory, the totient of a positive integer n is defined to be the number of positive integers less than or equal to n that are coprime to n.

Given an integer n (1 <= n <= 10^6). Compute the value of the totient .

Input

First line contains an integer T, the number of test cases. (T <= 20000)

T following lines, each contains an integer n.

Output

T lines, one for the result of each test case.

Example

Input:
5
1
2
3
4
5

Output:
1
1
2
2
4


Added by:Race with time
Date:2009-03-27
Time limit:1s
Source limit:50000B
Languages:All except: CLOJ ERL F# JS PERL 6 TECS

hide comments
2010-08-25 15:24:57 Mohammad Kotb
Can't optimize in this problem more than that!!!
TLE !!!!

Last edit: 2010-08-25 15:25:14
2010-07-11 18:37:05 I M back
my C code is giving correct output for all 10^6 cases (keeping t=10^6 & n=1 -> 10^6) in 0m0.465s.....still getting <<< Time limit Exceeded >>> :(
2010-05-29 16:09:08 Priyank
Be careful be getchar() ... cost me many WA and TLE. Just used scanf and got accepted.
2010-05-18 07:24:05 Abhisek Banerjee
why am i getting tle?
2010-04-26 08:27:20 Ishan
give some more test cases.my program seems to be giving correct output for all boundary cases.yet i am getting wa.
2010-04-06 03:08:58 黃 正 威
In fact, there is a way computing phi in O(N log N)
2009-10-05 07:55:54 Drew Saltarelli
Strict time limit. Perhaps you should increase it to give slower I/O languages a chance.
2009-10-05 07:55:54 amaroq
Is this an early April fool joke? The problem number (4141) would suggest it...

[Sorry if I spoiled it]
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.