FaltuTech.Club : Fane of Advanced Logical Thriving Utopian Technical Club

Fibonacci Series Program in Java

using While



import java.io.*;

class FabSeries{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		System.out.print("How may elements you need of Fab Series");
		int max = Integer.parseInt(br.readLine());
		
		System.out.println(); // just to print a new line
		int p1 = 1;
		int previous = 0;
		int stop=1;
		while(stop

Recursive



class Fibo{
	private int Int = 1;
	private int Add = 0;
	private void fibo(int x, int Add){

	    if(x>100)
	    return;
	
	    System.out.print(x + ",");
	    int temp = x;
	    x +=Add;
	    Add=temp;
	    fibo(x,Add);
	}

	public void example(){
	
	    fibo(Int,Add);

	}
}