Factorial · Factorielle
Factorial
The factorial n! is the product 1 * 2 * 3 * ... * n. By definition 0! is 1.
Start a result at 1, then multiply it by every integer from 2 up to n in a loop. (The tests keep n at most 10, so the answer fits in an int.)
Factorielle
La factorielle n! est le produit 1 * 2 * 3 * ... * n. Par définition 0! est 1.
Commencez un résultat à 1, puis multipliez-le par chaque entier de 2 jusqu'à n dans une boucle. (Les tests maintiennent n au plus à 10, afin que la réponse tienne dans un int.)
Complete int factorial(int n) to return n! = 1 * 2 * ... * n. Assume 0 <= n <= 10, and factorial(0) is 1. · Complétez int factorial(int n) pour retourner n! = 1 * 2 * ... * n. Supposez 0 <= n <= 10, et factorial(0) est 1.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.