Pagini recente » Cod sursa (job #2720689) | Cod sursa (job #2858891) | Cod sursa (job #89734) | Cod sursa (job #3229882) | Cod sursa (job #43161)
Cod sursa(job #43161)
Program fractii;
Var f:text;
n,s,i,j:longint;
function prime_intre_ele(a,b:longint):boolean;
var r:longint;
begin
repeat
r:=a mod b;
a:=b;
b:=r;
until(r=0);
prime_intre_ele:=false;
if a=1 then prime_intre_ele:=true;
end;
Begin
assign(f,'fractii.in');
reset(f);
readln(f,n);
close(f);
s:=2*n-1+2*n-4;
for i:=2 to n-2 do
for j:=i+2 to n do
if not((i mod 2=0) and (j mod 2=0)) then
if not((i mod 3=0) and (j mod 3=0)) then
if not((i mod 5=0) and (j mod 5=0)) then
if not((i mod 7=0) and (j mod 7=0)) then
if not((i mod 11=0) and (j mod 11=0)) then
if not((i mod 13=0) and (j mod 13=0)) then
if not((i mod 17=0) and (j mod 17=0)) then
if not((i mod 19=0) and (j mod 19=0)) then
if not((i mod 23=0) and (j mod 23=0)) then
if not((i mod 29=0) and (j mod 29=0)) then
if not((i mod 31=0) and (j mod 31=0)) then
if not((i mod 37=0) and (j mod 37=0)) then
if not((i mod 41=0) and (j mod 41=0)) then
if not((i mod 43=0) and (j mod 43=0)) then
if not((i mod 47=0) and (j mod 47=0)) then
if not((i mod 53=0) and (j mod 53=0)) then
if j mod i>0 then
if j mod i=1 then s:=s+2
else if prime_intre_ele(i,j) then s:=s+2;
assign(f,'fractii.out');
rewrite(f);
Writeln(f,s);
close(f);
End.