diff --git a/src/main/java/com/thealgorithms/maths/FibonacciNumber.java b/src/main/java/com/thealgorithms/maths/FibonacciNumber.java index 17a8de61..c39f2a8b 100644 --- a/src/main/java/com/thealgorithms/maths/FibonacciNumber.java +++ b/src/main/java/com/thealgorithms/maths/FibonacciNumber.java @@ -17,8 +17,8 @@ public class FibonacciNumber { * Check if a number is perfect square number * * @param number the number to be checked - * @return true if {@code number} is perfect square, otherwise - * false + * @return true if {@code number} is a perfect square, otherwise + * false */ public static boolean isPerfectSquare(int number) { int sqrt = (int) Math.sqrt(number); @@ -26,18 +26,17 @@ public class FibonacciNumber { } /** - * Check if a number is fibonacci number This is true if and only if at + * Check if a number is a Fibonacci number. This is true if and only if at * least one of 5x^2+4 or 5x^2-4 is a perfect square * * @param number the number - * @return true if {@code number} is fibonacci number, otherwise - * false + * @return true if {@code number} is a Fibonacci number, otherwise + * false * @link https://en.wikipedia.org/wiki/Fibonacci_number#Identification */ public static boolean isFibonacciNumber(int number) { - return ( - isPerfectSquare(5 * number * number + 4) || - isPerfectSquare(5 * number * number - 4) - ); + int value1 = 5 * number * number + 4; + int value2 = 5 * number * number - 4; + return isPerfectSquare(value1) || isPerfectSquare(value2); } }