Input
Output
public class FibonacciSeries { public static void main(String[] args) { int n = 7; System.out.println("Enter the number of terms for Fibonacci Series: " + n); int first = 0, second = 1; System.out.println("Fibonacci Series up to " + n + " terms:"); for (int i = 1; i <= n; i++) { System.out.print(first + " "); int next = first + second; first = second; second = next; } } }