Fibonnaci Numbers

import java.util.Scanner;


* @author asharda
public class fibonaccinumber {

* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(“Enter a number for which you want a fibonnaci number”);
Scanner in=new Scanner(;
int number=generatenumber(in.nextInt());
System.out.println(“Fibonnaci Number is “+number);


public static int generatenumber(int n)
{int sum;

return 0;
else if(n==1)
return 1;

return generatenumber(n-1) +generatenumber(n-2);




About qainterviews

Software Geek,QA Expert,Blogger
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s