Files
camperbot b3af21d50f chore(i18n,curriculum): update translations (#42487)
* chore(i18n,curriculum): update translations

* chore: Italian to italian

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
2021-06-14 11:34:20 -07:00

1.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
a302f7aae1aa3152a5b413bc Fattoriale di un numero 5 16013 factorialize-a-number

--description--

Restituisci il fattoriale del numero intero fornito.

Se l'intero è rappresentato con la lettera n, un fattoriale è il prodotto di tutti gli interi positivi minori o uguali a n.

I fattoriali sono spesso rappresentati con la notazione abbreviata n!

Per esempio: 5! = 1 * 2 * 3 * 4 * 5 = 120

Verranno passati alla funzione solo interi maggiori o uguali a zero.

--hints--

factorialize(5) dovrebbe restituire un numero.

assert(typeof factorialize(5) === 'number');

factorialize(5) dovrebbe restituire 120.

assert(factorialize(5) === 120);

factorialize(10) dovrebbe restituire 3628800.

assert(factorialize(10) === 3628800);

factorialize(20) dovrebbe restituire 2432902008176640000.

assert(factorialize(20) === 2432902008176640000);

factorialize(0) dovrebbe restituire 1.

assert(factorialize(0) === 1);

--seed--

--seed-contents--

function factorialize(num) {
  return num;
}

factorialize(5);

--solutions--

function factorialize(num) {
  return num < 1 ? 1 : num * factorialize(num - 1);
}

factorialize(5);