Fibonacci Series

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

Comments (0)

  • To add your comment please or

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

Got It!