Pagini recente » Cod sursa (job #1911168) | Cod sursa (job #98387) | Cod sursa (job #3218420) | Cod sursa (job #2516209) | Cod sursa (job #1066682)
#include <iostream>
#include <fstream>
using namespace std;
int t, n, s, p, cp;
int pow(int n)
{
p = n;
int i = 1;
while(i!=n)
{
p = p * n;
i = i+1;
}
return p;
}
int main()
{
fstream fin("cifra.in", ios::in);
fstream fout("cifra.out", ios::out);
fin>>t;
for(int i = 1; i<=t; i++)
{
fin>>n;
s = 0;
for(int j = 1; j<=n; j++)
{
s = s + pow(j);
}
fout<<s%10<<endl;
}
}