Analysis
本题大意为给定N(1<=N<=10^4) 求不大于N并与N互质的正整数个数。用欧几里得算法(辗转相除法)判断最大公约数是否为1即可。
Accepted Code
var
n,i,tot:longint;
function gcd(a,b:longint):longint;
begin
if a mod b=0 then
gcd:=b
else
gcd:=gcd(b,a mod b);
end;
begin
readln(n);
tot:=0;
for i:=1 to n do
if gcd(n,i)=1 then
inc(tot);
writeln(tot);
end.