Menu
Coddy logo textTech

Recap - Simple Math

Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 23 of 93.

challenge icon

Challenge

Easy

Write a function calculateFinalValue that takes initial, bonus, and divisor and returns the remainder after a series of operations.

Logic:

  1. Start with the initial value
  2. Add bonus to it using +=
  3. Double the result using *=
  4. Return the remainder when dividing by divisor

Parameters:

  • initial (Int): The starting value
  • bonus (Int): The value to add
  • divisor (Int): The number to divide by for the remainder

Returns: The remainder after performing all operations (Int)

Input constraints: The divisor is nonzero. All intermediate values fit in Int.

Try it yourself

fun calculateFinalValue(initial: Int, bonus: Int, divisor: Int): Int {
    // Write code here
}

All lessons in Fundamentals

Practice on your own: Kotlin playground