1 // Binet's formula for checking Fibonacci numbers is_fibonacci(x: i32) -> bool2pub fn is_fibonacci(x: i32) -> bool { 3 is_perfect_square(5 * x * x + 4) || is_perfect_square(5 * x * x - 4) 4 } 5 is_perfect_square(x: i32) -> bool6fn is_perfect_square(x: i32) -> bool { 7 if x < 0 { 8 return false; 9 } 10 let y = (x as f64).sqrt() as i32; 11 y * y == x 12 } 13