-
Notifications
You must be signed in to change notification settings - Fork 1
Math
jschanker edited this page Feb 16, 2016
·
1 revision
The code fragments below assume that generic_number_variable was previously set to an integer (or any decimal number where sensible) according to Variables. E.g.,
set generic_number_variable to 42
If one of these phrases doesn't seem to work in a larger expression or statement, try surrounding the entire code phrase with parentheses.
remainder of generic_number_variable divided by 10
- 10 can be replaced with a variable storing an integer.
generic_number_variable is even
generic_number_variable is odd
generic_number_variable is prime
generic_number_variable is whole
generic_number_variable is positive
generic_number_variable is negative
generic_number_variable is divisible by 10
square root generic_number_variable
absolute generic_number_variable
- sqrt generic_number_variable also works.
- generic_number_variable can be replaced with any numeric literal or even if generic_number_variable were set in the usual Ruby way via the assignment operator.
This can be accomplished via the following:
increase generic_number_variable by 10
Other options include e.g.,
decrease generic_number_variable by some_other_number_variable
multiply generic_number_variable by 10
divide generic_number_variable by some_other_number_variable