ETF - Euler Totient Function
Tác giả: RR
Ngôn ngữ: Pascal
{$R+,Q+}
{$Mode objFPC}
uses math;
const
FINP = '';
FOUT = '';
MAXN = 1000001;
var
f1,f2 : text;
phi : array[1..MAXN] of longint;
procedure openF;
begin
assign(f1,FINP); reset(f1);
assign(f2,FOUT); rewrite(f2);
end;
procedure closeF;
begin
close(f1);
close(f2);
end;
procedure init;
var
i,j:longint;
begin
for i:=1 to MAXN do phi[i]:=i;
for i:=2 to MAXN do
if phi[i]=i then //i la so nguyen to
begin
j:=i;
while j<=MAXN do
begin
phi[j]:=phi[j] div i*(i-1);
j+=i;
end;
end;
end;
function cal(n:longint):int64;
var
sum:int64;
begin
end;
procedure solve;
var
test,n:longint;
begin
read(f1,test);
for test:=1 to test do
begin
read(f1,n);
writeln(f2,phi[n]);
end;
end;
begin
openF;
init;
solve;
closeF;
end.