func fact(n: Int) -> Int { var result = 1 var i = 1 while i <= n { result *= i i += 1 } return result } let num = 5 let result = fact(n: num) print("\(num)! = \(result)")
To embed this program on your website, copy the following code and paste it into your website's HTML: