-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample6.js
More file actions
57 lines (47 loc) · 1.13 KB
/
Example6.js
File metadata and controls
57 lines (47 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// to take input from user from console we use require()
/*
const readLine = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
*/
// const readline = require("readline");
// const rl = readline.createInterface({
// input: process.stdin,
// output: process.stdout
// });
// rl.question("Enter a number: ",function(answer){
// const number = parseInt(answer);
// if(number > 0){
// console.log("Number is Positive");
// }
// else if(number < 0){
// console.log("Number is Negative");
// }
// else{
// console.log("Number is zero");
// }
// rl.close();
// });
// const number = parseInt(prompt("Enter a number: "));
// if (number > 0) {
// console.log("The number is positive");
// }
// else if (number == 0) {
// console.log("The number is zero");
// }
// else {
// console.log("The number is negative");
// }
const n = parseInt(process.argv[2]);
let fact = 1;
if(isNaN(n) || n <0){
console.log("Enter a valid Number");
}
else{
for(let i = 1;i<=n;i++){
fact *=i;
}
console.log(fact);
}