-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJS_HW_3.js
More file actions
17 lines (16 loc) · 858 Bytes
/
Copy pathJS_HW_3.js
File metadata and controls
17 lines (16 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
You need to print numbers from 1 to 100 to the console.
If the number is divisible by 3 without a remainder, then print “number is divisible by 3” to the console.
If the number is divisible by 5 without a remainder, then print “number is divisible by 5” to the console.
If the number is divisible by both 3 and 5 without a remainder, then print to the console “number is divisible by 3 by 5”.
The number 15 is evenly divisible by 3 and 5 -- an example of a message in the console.
*/
for (let a = 1; a <= 100; a++) {
if (a % 3 == 0 && a % 5 == 0) {
console.log("Number", a, "- divisible without remainder by both 3 and 5")
} else if (a % 3 == 0) {
console.log("Number", a, "- divisible without remainder by 3")
} else if (a % 5 == 0) {
console.log("Number", a, "- divisible without remainder by 5")
}
}