Day 17
Problem Statement:-Recursion: Fibonacci Numbers
very simple recursive fibonacci no problem.
Solution:-
public static int fibonacci(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
return fibonacci(n - 1) + fibonacci(n - 2);
}
Problem Statement:-Recursion: Fibonacci Numbers
very simple recursive fibonacci no problem.
Solution:-
public static int fibonacci(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
return fibonacci(n - 1) + fibonacci(n - 2);
}
No comments:
Post a Comment