Guest User

Naive Fibonacci generator

a guest
Aug 2nd, 2011
268
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2. public class NaiveFibonacci{
  3.     private Vector<int> fibSequence;
  4.  
  5.     public void NaiveFibonacci(){
  6.     this.fibSequence = new Vector<int>();
  7.     this.fibSequence.add(0);
  8.     this.fibSequence.add(1);
  9.     }
  10.  
  11.     public int nextFibonacciNumber(){
  12.     int fibSize = this.fibSequence.size();
  13.     return this.fibSequence.add(this.fibSequence.elementAt(fibSize - 1) + this.fibSequence.elementAt(fibSize - 2));
  14.     }
  15. }
RAW Paste Data