Last active
March 8, 2022 06:36
-
-
Save SpaYco/72aa67281a40fe5f2019d86da394c63e to your computer and use it in GitHub Desktop.
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
######## Make any even/odd calculator with this method ######## | |
######################## Get Crazy ########################### | |
def getCrazy(n) | |
result = "case x\n" | |
1..n.times do |number| | |
result += " when #{number}\n" | |
result += " p '#{number % 2 == 0 ? 'even': 'odd'}'\n" | |
end | |
result += "else\n p 'I\\\'m not there yet'\nend" | |
end | |
# getCrazy(500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
.even?
method instead of% 2 == 0
.