Skip to content

Instantly share code, notes, and snippets.

@Aditi3
Created June 20, 2021 06:58
Show Gist options
  • Select an option

  • Save Aditi3/d47e39de663521a8c1e5446367328809 to your computer and use it in GitHub Desktop.

Select an option

Save Aditi3/d47e39de663521a8c1e5446367328809 to your computer and use it in GitHub Desktop.
Factorial program in swift using function
import UIKit
func factorial(_ number: Int) -> Int {
var fact = 1
for n in 1...number {
fact = fact * n
}
return fact
}
let result = factorial(10)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment