You are viewing a single comment's thread. Return to all comments →
Solution in Swift only storing the last two items in the array to calculate the new value
func isFibo(n: Int) -> String { var nums = [0,1] while nums[1] < n { nums.swapAt(0, 1) nums[1] = nums.reduce(0, +) } return nums[1] == n ? "IsFibo" : "IsNotFibo" }
Seems like cookies are disabled on this browser, please enable them to open this website
Is Fibo
You are viewing a single comment's thread. Return to all comments →
Solution in Swift only storing the last two items in the array to calculate the new value