Is this actually recursion?

Report a typo

Which of these functions utilize recursion?

  1. fun f1(a : Int, b : Int) : Int = a + b
  2. fun f2(n: Int): Int {
       if (n == 0 || n == 1) return 1
       return n * f2(n - 1)
    }
  3. fun f3(n: Int): Int {
       var f = 1
       for (i in 1..n)
           f *= i
       return f
    }
  4. fun f4(n : Int) {
       if(n < 1) return
       print(n)
       f4(n-1)
    }

Select one or more options from the list
___

Create a free account to access the full topic