Created
March 2, 2016 01:07
-
-
Save trillerpfeife/643f46c0be39df5149d6 to your computer and use it in GitHub Desktop.
super crasy function checks whether n is dividable by 2 or subtractable by 5
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 check(n) { | |
var history = "(" + n; | |
var number = n; | |
while (number > 3) { | |
if ((number % 2)=== 0) { | |
number = number / 2; | |
history += ")/2" | |
} | |
else { | |
number = number - 5; | |
history += "-3" | |
} | |
} | |
return history +" = "+ number; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment