Cod sursa(job #1453416)

Utilizator Costin.StanciuStanciu Costin Costin.Stanciu Data 23 iunie 2015 14:46:57
Problema Cifra Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int j, i, n, c = 0, x;

    freopen("cifra.in", "r", stdin);
    freopen("cifra.out", "w", stdout);

    scanf("%d", &n);

    for (i = 1; i <= n; i++)
    {
        x = i;
        j = i - 1;
        while (j > 0)
        {
            x = x * i;
            j--;
        }
        c = c + x % 10;
    }
    c = c % 10;
    printf ("%d ", c);
    return 0;
}