Can you guess what this code in Swift does?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func secretFunction(of num: Int) -> Int { | |
if num == 1 { | |
return 1 | |
} else { | |
return num * secretFunction(of:num - 1) | |
} | |
} |
And what result would you see for the code below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x = 4 | |
let result = secretFunction(of: x) |
?
