/**
 * Accountants often need to calculate interest on a balance over a certain number of years at a given interest rate.
 * Complete the function below to calculate the final balance after applying compound interest.
 *
 * @param balance The initial balance.
 * @param rate The annual interest rate.
 * @param years The number of years the interest is applied.
 * @return The final balance after applying interest.
 *
 * Formula:
 * The formula to calculate compound interest is: balance * (1 + rate).pow(years)
 *
 * Note:
 * The ".pow()" function is used to raise a number to the power of another in Kotlin.
 *
 * Difficulty: Hard
 */
fun calculateInterest(balance: Double, rate: Double, years: Int): Double {

    var finalBalance = balance
    val interest = rate / 100

    repeat(if (years >= 0) years else 0) {
        finalBalance += finalBalance * interest
    }

    return finalBalance
}
/**
 * Accountants often need to calculate interest on a balance over a certain number of years at a given interest rate.
 * Complete the function below to calculate the final balance after applying compound interest.
 *
 * @param balance The initial balance.
 * @param rate The annual interest rate.
 * @param years The number of years the interest is applied.
 * @return The final balance after applying interest.
 *
 * Formula:
 * The formula to calculate compound interest is: balance * (1 + rate).pow(years)
 *
 * Note:
 * The ".pow()" function is used to raise a number to the power of another in Kotlin.
 *
 * Difficulty: Hard
 */
fun calculateInterest(balance: Double, rate: Double, years: Int): Double {
/**
 * Accountants often need to calculate interest on a balance over a certain number of years at a given interest rate.
 * Complete the function below to calculate the final balance after applying compound interest.
 *
 * @param balance The initial balance.
 * @param rate The annual interest rate.
 * @param years The number of years the interest is applied.
 * @return The final balance after applying interest.
 *
 * Formula:
 * The formula to calculate compound interest is: balance * (1 + rate).pow(years)
 *
 * Note:
 * The ".pow()" function is used to raise a number to the power of another in Kotlin.
 *
 * Difficulty: Hard
 */
fun calculateInterest(balance: Double, rate: Double, years: Int): Double {

    var finalBalance = balance
    val interest = rate / 100

    repeat(if (years >= 0) years else 0) {
        finalBalance += finalBalance * interest
    }

    return finalBalance
}