Menu
Coddy logo textTech

Recap - Simple Math

Part of the Fundamentals section of Coddy's Swift journey — lesson 19 of 86.

challenge icon

Challenge

Easy
Write a function calculateStats that takes two integers a and b, and returns a combined result using multiple arithmetic operations.

Calculate the following expression: the sum of a and b, plus their product, minus the integer quotient of a divided by b, plus the remainder of a divided by b.

Formula: (a + b) + (a * b) - (a / b) + (a % b)

Parameters:

  • a (Int): The first integer
  • b (Int): The second integer

Returns: The result of the combined expression (Int)

Try it yourself

func calculateStats(a: Int, b: Int) -> Int {
    // Write code here
}

All lessons in Fundamentals