“func fibonacci(n: Int) { var n1 = 0 var n2 = 1 if n == 0 { print("Invalid") } else if n == 1 { print(n1) } else if n == 2 { print(n1, n2) } else { var array = [n1, n2] for _ in 2..<n { let n3 = n1 + n2 n1 = n2 n2 = n3 array.append(n3) } print(array) } } }” Code Answer


func fibonacci(n: Int) { var n1 = 0 var n2 = 1 if n == 0 { print("Invalid") } else if n == 1 { print(n1) } else if n == 2 { print(n1, n2) } else { var array = [n1, n2] for _ in 2..
whatever by Impossible Ibis on Aug 10 2021 Comment
0
Add a Grepper Answer

Whatever answers related to “func fibonacci(n: Int) { var n1 = 0 var n2 = 1 if n == 0 { print("Invalid") } else if n == 1 { print(n1) } else if n == 2 { print(n1, n2) } else { var array = [n1, n2] for _ in 2..<n { let n3 = n1 + n2 n1 = n2 n2 = n3 array.append(n3) } print(array) } } }”


Whatever queries related to “func fibonacci(n: Int) { var n1 = 0 var n2 = 1 if n == 0 { print("Invalid") } else if n == 1 { print(n1) } else if n == 2 { print(n1, n2) } else { var array = [n1, n2] for _ in 2..<n { let n3 = n1 + n2 n1 = n2 n2 = n3 array.append(n3) } print(array) } } }”





More “Kinda” Related Whatever Answers View All Whatever Answers »




Browse Popular Code Answers by Language




Browse Other Code Languages




X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.