- Read Tutorial
- Watch Guide Video
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:
The same applies to subtraction, multiplication and division. If you want to use exponents, you can use two asterisk symbols like this:
The list of arithmetic functions to use in a Ruby program is below: