Problema: 1153
Enunciado:
Ler um valor N. Calcular e escrever seu respectivo fatorial. Fatorial de N = N * (N-1) * (N-2) * (N-3) * ... * 1.
O fatorial é calculado multiplicando os valores de 1 até n.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <iostream> using namespace std; int main() { int n; cin >> n; int fat = 1; for(int i = 1; i<=n;i++){ fat = fat*i; } cout << fat << endl; return 0; } |
Nenhum comentário:
Postar um comentário