Sun Aug 29 2021

Fibonacci Series

File Name: fibonacci-series.java

import java.io.*;

class fibonacci {
	public static void main(String args[ ]) {
		int start = 1, end = 0, temp = 0;
		System.out.println("Program for Fibonacci Series");

		/* Loop the process using 'do while' loop */
		do {
			System.out.println(temp);
			temp = start + end;
			start = end;
			end = temp;											
		}
		while(end < Integer.parseInt(args[0]));
	}
}



/* Output */
java fibonacci 50
Program for Fibonacci Series
0
1
1
2
3
5
8
13
21
34
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.