Ad
Code
Diff
  • fun fact(n: Int):Int {
      return  if (n == 0) 1
        else fact(n-1) * n
    }
    • fun fact(n: Int): Int {
    • if (n == 0) {
    • return 1
    • }
    • return fact(n-1) * n
    • fun fact(n: Int):Int {
    • return if (n == 0) 1
    • else fact(n-1) * n
    • }
Code
Diff
  • fun fact(n: Int)= (1..n).reduce { acc, i -> acc * i }
    
    
    • fun fact(n: Int): Int {
    • return (1..n).reduce { acc, i -> acc * i }
    • }
    • fun fact(n: Int)= (1..n).reduce { acc, i -> acc * i }
Code
Diff
  • fun returnNum(n:Int)=n
    
    • fun returnNum(n:Int): Int{
    • return n
    • }
    • fun returnNum(n:Int)=n