Can you guess what this code in Swift does?

func secretFunction(of num: Int) -> Int {
if num == 1 {
return 1
} else {
return num * secretFunction(of:num - 1)
}
}
view raw puzzle2_1.dart hosted with ❤ by GitHub

And what result would you see for the code below:

let x = 4
let result = secretFunction(of: x)
view raw puzzle2_2.swift hosted with ❤ by GitHub

?

Puzzle

More like this

Get in touch

Get in touch

Frankfurt am Main, Germany (Sales)

60354

Eckenheimer Schulstraße, 20

+38 (098) 630-49-85

info@a5.ua

Kharkiv, Ukraine (Development)

61023

Trinklera street, 9

+38 (050) 908-31-07

info@a5.ua

Burgas, Bulgaria (Development)

8008

бул. „Транспортна“ 15, Northern Industrial Zone

+359 877 350129

info@a5.ua