Created
February 4, 2019 10:13
-
-
Save stevencurtis/33bf1be7d2873d2cf1508b3d1522dec9 to your computer and use it in GitHub Desktop.
Factorial Iterative
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 fact (_ num : Int) -> Int { | |
if num == 1 {return 1} | |
var result = 1 | |
for i in 1...num { | |
result = result * i | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment