BeginnerOperators

Arithmetic Operators

Basic math operations in Kotlin.

kotlin
fun main() {
    val a = 10
    val b = 3
    println(a + b)
    println(a - b)
    println(a * b)
    println(a / b)
    println(a % b)
}
Output
13 7 30 3 1

Explanation

/ on integers performs integer division (no decimal). % gives the remainder.

Related Tutorials