Factorial: 1부터 어떤 양의 정수 n까지의 정수를 모두 곱한 것, n!
func factorial(num: Int) -> Int { var total: Int = num if num == 0 { return 1 } total *= factorial(num: num-1) return total }
func pibonachi(num: Int) -> Int { var index: Int = 0 if num == 1 || num == 2 { return 1 } index += pibonachi(num: num-2) + pibonachi(num: num-1) return index }
func piboSecond(num: Int) -> Int { if num == 1 || num == 2 { return 1 } return piboSecond(num: num-1) + piboSecond(num: num-2) }
func piboThird(num: Int) -> Int { return (num == 1 || num == 2) ? 1 : piboThird(num: num-1) + piboThird(num: num-2) }
func pivoTotal(num: Int) -> Int { var total: Int = 0 for i in 1...num { total += piboThird(num: i) } return total }