hello all. i am working on the Fibonacci sequence constructor and i was wondering if i posted wha ti have so far if you could tell me if im on the right trac or not and maybe give me a few pointers to help me get it right heres what i have for code and the assignment so you can see what i have to do

public class FibonacciGenerator
{
    public static int fib(int n)
    {
                int fold1=0, fold2=1;
     public getNumber()
                for(int i=0; i<n; i++)
                {
                    int savefold1 = fold1;
                    fold1 = fold2;
                    fold2 = savefold1 + fold2;
                }
                return fold1;
    }
}

Write a program that prompts the user for n and prints the nth value in the Fibonacci sequence. Use a class FibonacciGenerator with a method nextNumber .

There is no need to store all values for fn. You only need the last two values to compute the next one in the series:
fold1 = 1;
fold2 = 1;
fnew = fold1 + fold2;
After that, discard fold2 , which is no longer needed, and set fold2 to fold1 and fold1 to fnew .