Created
July 25, 2014 07:01
-
-
Save macikokoro/478c9519dae962abb1c4 to your computer and use it in GitHub Desktop.
Loop to check for number divisible by 4 and reducing by 75%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numSheep = 4; | |
var monthsToPrint = 12; | |
for (var monthNumber = 1; monthNumber <= monthsToPrint; monthNumber++) { | |
if (monthNumber % 4 === 0) { | |
numSheep = numSheep / 4; | |
console.log("Removing " + numSheep * 3 + " sheep from the population. Phew!"); | |
} else if (numSheep > 10000) { | |
numSheep = numSheep / 2; | |
console.log("Removing " + numSheep + " sheep from the population. Phew!"); | |
} | |
numSheep *= 4; | |
console.log("There will be " + numSheep + " sheep after " + monthNumber + " month(s)!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment