-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday4.js
More file actions
59 lines (53 loc) · 965 Bytes
/
day4.js
File metadata and controls
59 lines (53 loc) · 965 Bytes
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
56
57
58
console.log("Numbers from 1 to 10 : ")
for(let i=1;i<=10;i++){
console.log(i)
}
console.log("Multiplication table of 5")
for(let i=1;i<=10;i++){
console.log(5*i)
}
let i=1,sum=0;
while(i<=10){
sum+=i
i++;
}
console.log(`Sum of numbers from 1 to 10: ${sum}`)
console.log("Numbers from 10 to 1 : ")
let j=10
while(j>0){
console.log(j)
j--
}
console.log("Numbers from 1 to 5 : ")
let k=1
do{
console.log(k)
k++
}
while(k<=5);
let n=5
let num=n
let product=1;
do{
product*=num
num--;
}while(num>0);
console.log(`Factorial of ${n} : ${product}`)
console.log("Star pattern : ")
for(let i=0;i<n;i++){
let s="";
for(j=0;j<i+1;j++){
s+="*"
}
console.log(s);
}
console.log("Number from 1 to 10, skipping 5 : ");
for(let i=1;i<=10;i++){
if(i==5) continue;
console.log(i);
}
console.log("Number from 1 to 10, stopping before 7 : ");
for(let i=1;i<=10;i++){
if(i==7) break;
console.log(i);
}