根据数学定义来模拟
#include <iostream>
using namespace std;
typedef long long ll;
int n;
int main(){
scanf("%d",&n);
while(n--){
int x;
scanf("%d",&x);
int res = x;
for(int i = 2; i <= x/i; i++){
if(x % i == 0){//i相当于Pi
res = res / i * (i - 1);
while(x % i == 0){
x /= i;
}
}
}
if(x > 1) res = res / x * (x - 1);
printf("%lld\n",res);
}
return 0;
}