Pagini recente » Cod sursa (job #2787934) | Cod sursa (job #612836) | Cod sursa (job #2051913) | Cod sursa (job #2322605) | Cod sursa (job #2742)
Cod sursa(job #2742)
program cifra;
var a,k,b:longint;
f,g:text;
function gasire(b:longint):byte;
var aux,i:longint;
begin
aux:=b;
for i:=1 to b-1 do begin
b:=b*aux;
b:=b mod 10;
end;{for}
gasire:=b;
end;
function ultima(b:longint):byte;
var j,s:longint;
begin
s:=0;
for j:=1 to b do
s:=s+gasire(j);
s:=s mod 10;
ultima:=s;
end;
begin
assign(f,'cifra.in');reset(f);
assign(g,'cifra.out');rewrite(g);
readln(f,a);
for k:=1 to a do begin
readln(f,b);
writeln(g,ultima(b));
end;
close(f);close(g);
end.