JavaScript
xxxxxxxxxx
const number = parseInt(prompt('Enter a positive integer: '));
if (number < 0) {
console.log('Error! Factorial for negative number does not exist.');
}
else if (number === 0) {
console.log(`The factorial of ${number} is 1.`);
}
else {
let fact = 1;
for (i = 1; i <= number; i++) {
fact *= i;
}
console.log(`The factorial of ${number} is ${fact}.`);
}
Enter a positive integer: 5 The factorial of 5 is 120.
Linux - anc-api-tools qanday o'rnatiladi
Linux - curvedns qanday o'rnatiladi
Linux - zenmap qanday o'rnatiladi
Python - Raqamning ijobiy, salbiy yoki 0 ekanligini tekshiring
C - Butun sondagi raqamlar sonini sanash
C++ - Raqam tub yoki oddiy emasligini tekshiring
C - Dinamik xotira ajratish yordamida eng katta raqamni toping
C++ - Kabisa yilini tekshiring
JavaScript - Satr ma'lum belgilar bilan boshlanishi va tugashini tekshiring
Kotlin - Raqamni teskari aylantirish
Linux - zstd qanday o'rnatiladi
C++ - Qism va qoldiqni toping
Linux - xbitmaps qanday o'rnatiladi
Kotlin - Raqamni n o‘nlik kasrgacha yaxlitlash
Kotlin - Sonning faktorialini toping
Java - Raqamni teskari aylantirish
Python - Excel (XLSX) fayllarini yozish
Java - Piramida va naqsh yarating
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month