diff --git a/Java/FibonacciSeries.java b/Java/FibonacciSeries.java new file mode 100644 index 0000000..0a28b78 --- /dev/null +++ b/Java/FibonacciSeries.java @@ -0,0 +1,21 @@ +import java.util.Scanner; + +public class FibonacciSeries { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the number of terms in Fibonacci series: "); + int n = scanner.nextInt(); + + int first = 0, second = 1; + System.out.print("Fibonacci Series: " + first + ", " + second); + + for (int i = 2; i < n; i++) { + int next = first + second; + System.out.print(", " + next); + first = second; + second = next; + } + + scanner.close(); + } +}