12:22 am - Tuesday May 22, 2018

Java Example Program for fibonacci series

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/* java program for Fibnacci series*/
/**
*@author:Candidjava.com
*@Description:Program for find the Fibonacci series of a given number
*/
public class Fibonacci {
	public static void main(String[] args) {
		int n;
		int c = 0;
		int a = 0;
		int b = 1;
		System.out.println("Fibonacci series:");
		for (int i = 1; i <= 10; i++) {
			a = b;
			b = c;
			c = a + b;
			System.out.println(c); // Display the value of c
		}
	}
}

Output:

1
1
2
3
5
8
13
21
34
55

Filed in: Sample Programs in java

Comments are closed.