Pagini recente » Cod sursa (job #506560) | Cod sursa (job #2926630) | Cod sursa (job #9581) | Cod sursa (job #31936) | Cod sursa (job #249995)
Cod sursa(job #249995)
var t,i:integer;
n:longint;
f,g:text;
function uc(n:longint):integer;
var i:longint;
j,p:0..4;
ucs,uca,uci:0..9;
begin
ucs:=0;
for i:=1 to n do
begin
p:=i mod 4;
if p=0 then p:=4;
uca:=1;
uci:=i mod 10;
for j:=1 to p do uca:=(uca*uci) mod 10;
ucs:=(ucs+uca) mod 10;
end;
uc:=ucs;
end;
begin
assign(f,'cifra.in');
assign(g,'cifra.out');
reset(f);
rewrite(g);
readln(f,t);
for i:=1 to t do
begin
readln(f,n);
writeln(g,uc(n));
end;
close(f);
close(g);
end.