Pagini recente » Cod sursa (job #1254909) | Cod sursa (job #2146631) | Cod sursa (job #1815680) | Cod sursa (job #283261) | Cod sursa (job #2801)
Cod sursa(job #2801)
var i,j,r,c,x,t:integer;
f,g:text;
n:longint;
function cif(n:longint):byte;
var c:byte;
begin
c:=n mod 10;
for i:=1 to n-1 do
begin
c:=c*n;
c:=c mod 10;
end;
cif:=c;
end;
begin
assign(f,'cifra.in');reset(f);
assign(g,'cifra.out');rewrite(g);
readln(f,t);
for r:=1 to t do
begin
readln(f,n); x:=0;
for j:=1 to n do
begin
x:=x+cif(j);
x:=x mod 10;
end;
writeln(g,x);
end;
close(f);close(G);
end.