Pagini recente » Cod sursa (job #2664848) | Cod sursa (job #2378992) | Cod sursa (job #690306) | Cod sursa (job #1223036) | Cod sursa (job #43143)
Cod sursa(job #43143)
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 j mod i>0 then
if prime_intre_ele(i,j) then s:=s+2;
assign(f,'fractii.out');
rewrite(f);
Writeln(f,s);
close(f);
End.