Skip to content

Commit 3c4e522

Browse files
committed
docs: add Javadoc to FibonacciSeries
1 parent fd0bcb7 commit 3c4e522

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/main/java/com/thealgorithms/recursion/FibonacciSeries.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
package com.thealgorithms.recursion;
22

3-
/*
4-
The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones,
5-
starting with 0 and 1.
6-
NUMBER 0 1 2 3 4 5 6 7 8 9 10 ...
7-
FIBONACCI 0 1 1 2 3 5 8 13 21 34 55 ...
8-
*/
3+
/**
4+
* The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones,
5+
* starting with 0 and 1.
6+
* <p>
7+
* Example:
8+
* 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ...
9+
* </p>
10+
*/
911

1012
public final class FibonacciSeries {
1113
private FibonacciSeries() {
14+
1215
throw new UnsupportedOperationException("Utility class");
1316
}
17+
18+
/**
19+
* Calculates the nth term in the Fibonacci sequence using recursion.
20+
*
21+
* @param n the position in the Fibonacci sequence (must be non-negative)
22+
* @return the nth Fibonacci number
23+
* @throws IllegalArgumentException if n is negative
24+
*/
1425
public static int fibonacci(int n) {
1526
if (n < 0) {
1627
throw new IllegalArgumentException("n must be a non-negative integer");

0 commit comments

Comments
 (0)