Integer Arithmetic Guide for a Ruby Program
Being able to compute mathematical equations in a program is a critical task for many programs. In this lesson, we are going to see how to use integer arithmetic in Ruby.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

Being able to compute mathematical equations in a program is a critical task for most programs in some form or another. In this lesson, we are going to see how to use integer arithmetic in Ruby.

Addition is as simple as a script like this:

p 5+5

The same applies to subtraction, multiplication and division. If you want to use exponents, you can use two asterisk symbols like this:

p 5**5

The list of arithmetic functions to use in a Ruby program is below:

  • + for addition
  • - for subtraction
  • / for division
  • * for multiplication
  • ** for exponents