You are viewing a single comment's thread. Return to all comments →
func isFib(n: Int) -> Bool { let fiveNSquare: Double = 5*Double(n)*Double(n) return (sqrt(fiveNSquare+4) % 1 == 0) || (sqrt(fiveNSquare-4) % 1 == 0) } for var i = 1; i < textInput.count; i++ { if let n = Int(textInput[i]) { print(isFib(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 →