Pagini recente » Cod sursa (job #1140706) | Cod sursa (job #293322) | Cod sursa (job #3267640) | Cod sursa (job #177242) | Cod sursa (job #125904)
Cod sursa(job #125904)
program fractii;
var b,x,y,S,t1,t2 : longint;
f : text;
function prime(a,b:longint):boolean;
var ok : boolean;
i,j : longint;
begin
ok := true;
if a=b then ok := false;
if (a mod b=0) and (b<>1) then ok := false;
if (b mod a=0) and (a<>1) then ok := false;
if ok then
if a>b then
for i := 2 to b do
if (a mod i=0) and (b mod i = 0) then
begin
ok := false;
break;
if ok then end;
if a<b then
for j := 2 to a do
if (a mod j=0) and (b mod j = 0) then
begin
ok := false;
break;
end;
prime := ok;
end;
begin
assign(f,'fractii.in');
reset(f);
read(f,b);
close(f);
S := 1;
for x := 1 to b do
for y := 1 to b do
if prime(x,y) then S := S+1;
assign(f,'fractii.out');
rewrite(f);
write(f,S);
close(f);
end.