-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathloops.js
36 lines (18 loc) · 1.81 KB
/
loops.js
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
// 1. Code a `for` loop below that prints out every number from 1-100.
// 2. Code a `for` loop that calculates the sum of all numbers from 0 to 100.
// (Helpful Hint: Consider creating a variable that stores the value of the total sum before the loop begins and increments while the loop is running.)
// 3. Code a `for` loop that print out every perfect square number less than or equal to 100.
// (Helpful Hint: Consider using the javascript function `Math.pw`. Notice that this exercise also requires a conditional statement.)
// 4. Code a `for` loop that prints out every even number from 1-100.
// (Helpful Hint: Consider using the remainder operator `%`. Notice that this exercise also requires a conditional statement.)
// 5. Code a `for` loop that prints out every number that ends in a 7 from 7-1007.
// (Helpful Hint: Consider using the remainder operator `%`. Notice that this exercise also requires a conditional statement.)
// 6. Print out every multiple of three from 1-100.
// (Helpful Hint: Consider using the remainder operator `%`. Notice that this exercise also requires a conditional statement.)
// CHALLENGE 1: If you got one grain of rice on day 1, two grains of rice on day 2, and four grains of rice on day 3, and it kept doubling like that, print out a daily report of how much rice you'd receive on each day for 30 days.
// (Helpful Hint: Consider using Math.pow())
// CHALLENGE 2: Print out multiples of two, another list of multiples of three, and then a third list of items which appear in both lists.
// (Helpful Hint: Consider using multiple for loops to begin.)
// CHALLENGE 3: Print out numbers which are multiples of 3 OR multiples of 2, but not multiples of both.
// (Helpful Hint: Consider using a logical operator for "OR")
// SUPER CHALLENGE: Print out the first 40 numbers in the Fibonacci sequence.