From 3c4e522598fdb50474b47c902c7b51fd74efb85f Mon Sep 17 00:00:00 2001 From: Chahat Date: Fri, 16 Jan 2026 20:31:22 -0600 Subject: [PATCH 1/2] docs: add Javadoc to FibonacciSeries --- .../recursion/FibonacciSeries.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java b/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java index 9bc6da2f7443..d3ffbdac3dbb 100644 --- a/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java +++ b/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java @@ -1,16 +1,27 @@ package com.thealgorithms.recursion; -/* - The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones, - starting with 0 and 1. - NUMBER 0 1 2 3 4 5 6 7 8 9 10 ... - FIBONACCI 0 1 1 2 3 5 8 13 21 34 55 ... -*/ +/** + * The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones, + * starting with 0 and 1. + *

+ * Example: + * 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ... + *

+ */ public final class FibonacciSeries { private FibonacciSeries() { + throw new UnsupportedOperationException("Utility class"); } + + /** + * Calculates the nth term in the Fibonacci sequence using recursion. + * + * @param n the position in the Fibonacci sequence (must be non-negative) + * @return the nth Fibonacci number + * @throws IllegalArgumentException if n is negative + */ public static int fibonacci(int n) { if (n < 0) { throw new IllegalArgumentException("n must be a non-negative integer"); From 51f56cdf434dbf6fbfc097a80323dea2442a8248 Mon Sep 17 00:00:00 2001 From: Chahat Date: Fri, 16 Jan 2026 20:41:13 -0600 Subject: [PATCH 2/2] fix: make small adjustment --- src/main/java/com/thealgorithms/recursion/FibonacciSeries.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java b/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java index d3ffbdac3dbb..9c809858099e 100644 --- a/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java +++ b/src/main/java/com/thealgorithms/recursion/FibonacciSeries.java @@ -11,7 +11,6 @@ public final class FibonacciSeries { private FibonacciSeries() { - throw new UnsupportedOperationException("Utility class"); }