Advertisements
Home > Java > Java Program to find fibonnaci series up to a particular number – Q4

Java Program to find fibonnaci series up to a particular number – Q4


Q4: Java Program to find factorial of a given number without recursion

The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones.

For example:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …

class fibseries{
	public static void main(String args[]){
		int a = Integer.parseInt(args[0]);
		int f=0, f1=0, f2=1;
		System.out.print("Fibbonacci Series: ");
		for(int i=0; i<a; i++){
			System.out.print(f1 + " ");
			f = f1 + f2;
			f1 = f2;
			f2 = f;
		}
	}
}

… from College notes (BCA/MCA assignments):


Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: