Arithmetic and Operators
Math operations.
Basic Arithmetic
Ruby supports the familiar operators: +, -, *, and /.
puts 5 + 3
puts 5 - 3
puts 5 * 3
puts 6 / 3The Modulo Operator
% returns the remainder of a division. It is great for checking divisibility.
puts 10 % 3
puts 10 % 2All lessons in this course
- Integers and Floats
- Arithmetic and Operators
- The Math Module
- Rational and BigDecimal