0Pricing
Ruby Academy · Lesson

Arithmetic and Operators

Math operations.

Basic Arithmetic

Ruby supports the familiar operators: +, -, *, and /.

puts 5 + 3
puts 5 - 3
puts 5 * 3
puts 6 / 3

The Modulo Operator

% returns the remainder of a division. It is great for checking divisibility.

puts 10 % 3
puts 10 % 2

All lessons in this course

  1. Integers and Floats
  2. Arithmetic and Operators
  3. The Math Module
  4. Rational and BigDecimal
← Back to Ruby Academy