Skip to content

Added Java_Fibonacci_recursion.java #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Add your name at the end of the list after Successfull contribution.

osifalujoi1
fharookshaik
cozyDoomer
AasthaGoyalgit
Expand Down
3 changes: 3 additions & 0 deletions Languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Hello there!!

## Code already developed in this programming language.

- BASIC
- Bash
- C
- C#
- C++
- Dart
- Fortran
- Go
- Haskell
- Java
Expand All @@ -21,6 +23,7 @@ Hello there!!
- Lua
- Matlab
- Miranda
- Octave
- PHP
- Powershell Script
- Python
Expand Down
20 changes: 20 additions & 0 deletions fibonacci_series/Java/Java_Recursive/Java_Fibonacci_Recursion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package java_recursive;
import java.util.Scanner;
class Fibonacci {
public static int fibonacci(int n) {
if (n <= 1){
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("How many terms would you like in the series?: ");
int n = input.nextInt();
for (int i = 0; i < n; i++){
System.out.print(fibonacci(i) + " ");
}

}
}