Simple Fibonacci Series


private void fibonacci(List list,int arg){
 if(arg==0){
 list.add(0);
 }else{
 if(list.isEmpty()){
 list.add(0);
 list.add(1);
 }
 int temp = (int)list.get(list.size()-1) + (int)list.get(list.size()-2);
 if(arg>=temp){
 list.add(temp);
 fibonacci(list,arg);
 }
 }
 }
Advertisements

Posted on February 26, 2014, in Education. Bookmark the permalink. Leave a comment.

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 )

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

%d bloggers like this: