Pagini recente » Cod sursa (job #2235735) | Cod sursa (job #1147295) | Cod sursa (job #2947437) | Infoarena Monthly 2014 - Runda 2 | Cod sursa (job #148525)
Cod sursa(job #148525)
var f,g:text;
t,n,i:longint;
function up(x,y:longint):byte;
begin
if y=0 then up:=1
else
up:=(up(x,y-1)*x) mod 10;
end;
function suma(z:longint):longint;
begin
if z=0 then suma:=0
else
suma:=(suma(z-1)+up(z,z)) mod 10;
end;
begin
assign(f,'date.in');
assign(g,'date.out');
reset(f);
rewrite(g);
readln(f,t);
for i:=1 to t do
begin
readln(f,n);
writeln(g,suma(n));
end;
close(f);
close(g);
end.