阶乘

2017-11-16  本文已影响0人  Wang99

func getSum(number: Int) -> Int {
//求某个数阶乘的结果
func getFactorIal(num: Int) -> Int {
var sum = 1
for _ in 1...num {
sum += 1
}
return sum
}
var total = 0
for item in 1...number {
total += getFactorIal(num: item)
}
return total
}

print(getSum(number: 3))

上一篇 下一篇

猜你喜欢

热点阅读