Buy NowTarantulo.lt recommends this store. We buy games here!

Javascript tipiniai uždaviniai

Šiame įraše kelsiu įvairius tipinius uždavinius, kurie bus sprendžiami su JavaScript.

Faktorialai

Faktorialų skaičiavimas su paaiškinimais.

Faktorialų pvz.


4! = 4 * 3 * 2 * 1 = 24
5! = 5 * 4 * 3 * 2 * 1 = 120

var solution = 1;

for (var x = 5; x > 0; x = x - 1) {
      console.log(solution + " " + x);
      solution = solution * x;
      console.log("Suma: " + solution / x + " * " + x + " = "+ solution )
}
console.log("Sprendimas: " + solution)

 

Add a Comment

Your email address will not be published. Required fields are marked *