Created
July 19, 2016 01:13
-
-
Save adriculous/2c634a2b81a9907d18d2284abe58b336 to your computer and use it in GitHub Desktop.
"Always Three" First Ruby Script (courtesy of Skillcrush)
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
# You are now at the Always 3 script. It's in Ruby, girl. Hello and welcome! | |
# Ask the person (user) to provide a number. Any number. | |
puts "Please, give me your number, I mean A number!" | |
# Hint: use 'gets' method, convert to an integer using 'to_i', make it a variable | |
i_number = gets.to_i | |
# add 5 | |
ii_number = i_number + 5 | |
# multiply by 2 | |
ii_number = ii_number * 2 | |
# subtract 4 | |
ii_number = ii_number - 4 | |
# divide by 2 | |
ii_number = ii_number / 2 | |
# subtract i_number from ii_number | |
fin_number = ii_number - i_number | |
# show fin_number back to person/user | |
puts "You know what it is! #{fin_number}, of course!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment