factorial
Calcula o fatorial de um número inteiro não negativo.
Sintaxe
typescript
factorial(value: number): numberParâmetros
| Nome | Tipo | Descrição |
|---|---|---|
value | number | Número inteiro não negativo. |
Retorno
| Tipo | Descrição |
|---|---|
number | O fatorial de value. |
Exemplo
typescript
factorial(5); // 120
factorial(0); // 1Notas
- Lança
TypeErrorse o valor não for inteiro não negativo. - O fatorial de 0 é 1 por definição.
