Pagini recente » Cod sursa (job #1041211) | Cod sursa (job #1016191) | Cod sursa (job #1199800) | Cod sursa (job #2869142) | Cod sursa (job #524841)
Cod sursa(job #524841)
var x,i,n,z,j:longint;
f,g:text;
FUNCTION fact(n:longint):longint;
var c,p,cp:longint;
begin
c:= n mod 10;
p:= n mod 100;
if c= 0 then cp:=0 else
if c=1 then cp:=1 else
if c=2 then if p=0 then cp:=1
else if p mod 4=1 then cp:=2
else if p mod 4=2 then cp:=4
else if p mod 4=3 then cp:=8
else if p mod 4=0 then cp:=6;
if c=3 then if p=0 then cp:=1
else if p mod 4=1 then cp:=3
else if p mod 4=2 then cp:=9
else if p mod 4=3 then cp:=7
else if p mod 4=0 then cp:=1;
if c=4 then if p=0 then cp:=1
else if p mod 2<>0 then cp:=4
else if p mod 2=0 then cp:=6;
if c=5 then if p=0 then cp:=1
else cp:=5;
if c=6 then if p=0 then cp:=1
else cp:=6;
if c=7 then if p=0 then cp:=1
else if p mod 4=1 then cp:=7
else if p mod 4=2 then cp:=9
else if p mod 4= 3 then cp:=3
else if p mod 4=0 then cp:=1;
if c=8 then if p=0 then cp:=1
else if p mod 4=1 then cp:=8
else if p mod 4=2 then cp:=4
else if p mod 4=3 then cp:=2
else if p mod 4=0 then cp:=6;
if c=9 then if p mod 1=0 then cp:=1
else if p=0 then cp:=1
else if p mod 2<>0 then cp:=9
else if p mod 2=0 then cp:=1;
fact:=cp;
end;
begin
assign(f,'cifra.in');reset(f);
assign(g,'cifra.out');rewrite(g);
readln(f,n);
for i:= 1 to n do begin
readln(f,x);
j:=0;
for z:=1 to x do
j:=j+ fact(z);
writeln(g,j mod 10);
end;
close(g);close(f);
end.