1161 - Soma de Fatoriais
20! = 2.432.902.008.176.640.000, ou seja, dois quintilhões quatrocentos e trinta e dois quatrilhões novecentos e dois trilhões oito bilhões cento e setenta e seis milhões seiscentos e quarenta mil.
Last updated
20! = 2.432.902.008.176.640.000, ou seja, dois quintilhões quatrocentos e trinta e dois quatrilhões novecentos e dois trilhões oito bilhões cento e setenta e seis milhões seiscentos e quarenta mil.
Last updated
#include <string.h>
#include <stdio.h>
long long int F[21];
long long int Fatorial(int n)
{
if (F[n] == 0)
F[n] = n * Fatorial(n - 1);
return F[n];
}
int main()
{
int M, N;
memset(F, 0, sizeof(F));
F[0] = 1;
while (scanf("%d %d", &M, &N) != EOF)
{
printf("%lld\n", Fatorial(M) + Fatorial(N));
}
return 0;
}#include <iostream>
#include <vector>
using namespace std;
vector<long long int> F;
long long int Fatorial(int n)
{
if (F[n] == 0)
F[n] = n * Fatorial(n - 1);
return F[n];
}
int main()
{
int M, N;
F.assign(21, 0);
F[0] = 1;
while (cin >> M >> N)
{
cout << Fatorial(M) + Fatorial(N) << endl;
}
return 0;
}let input = require("fs").readFileSync("/dev/stdin", "utf8");
let lines = input.trim().split("\n");
let F = Array(21);
F.fill(null);
F[0] = BigInt(1);
const Fatorial = (n) => {
if (!F[n]) F[n] = BigInt(n) * Fatorial(n - 1);
return F[n];
};
while (lines.length) {
let [M, N] = lines.shift().trim().split(' ').map((x) => parseInt(x));
console.log((Fatorial(M) + Fatorial(N)).toString());
}F = [0 for _ in range(21)]
F[0] = 1
def Fatorial(n):
if(F[n] == 0):
F[n] = n * Fatorial(n - 1)
return F[n]
while True:
try:
M, N = [int(x) for x in input().strip().split(' ')]
print(Fatorial(M) + Fatorial(N))
except EOFError:
break