Timus 1083. Factorials!!! Accepted Solution in C

#include <stdio.h>

int main()
{
    int i, n, k, sum;
    char input[24];

    gets(input);

    if(input[1] == ' ') {
        n = input[0] - '0';
        i = 2;
    } else {
        n = 10;
        i = 3;
    }

    k = i;
  
    while(input[i]) i++;

    k = i - k;
    sum = 1;

    for(i = n; i > 0; i -= k) sum *= i;

    printf("%d", sum);

    return 0;
}

Comments

Popular posts from this blog

Timus 1209. 1, 10, 100, 1000... accepted solution in C

Timus Problem 1086. Cryptography Accepted Solution in C