Created
December 30, 2015 03:40
-
-
Save khanghoang/995bf55518850491f143 to your computer and use it in GitHub Desktop.
squirrel's business
This file contains 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
function isInt(n){ | |
return Number(n) === n && n % 1 === 0; | |
} | |
function test(x) { | |
// x is the number that the last squirrel takes | |
return x * 5 + 1; | |
} | |
function thePreviousNuts(x) { | |
return x / 4 * 5 + 1; | |
} | |
var i = 1; | |
while (i < 1000) { | |
var temp = test(i); | |
for (var y = 1; y <= 4; y++) { | |
temp = thePreviousNuts(temp); | |
// console.log('y = ', y, 'temp =', temp); | |
if (!isInt(temp)) { | |
break; | |
} | |
if (y === 4) { | |
console.log(temp); | |
console.log(i); | |
i = 1001; | |
} | |
} | |
i += 1; | |
} | |
console.log('done'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment