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))
网友评论