1

I am trying to write the program for fibonacci series.But I am not able to execute the program.This program is from beginners guide.Can anyone please help me.

class fib {
    int fibo(int n) {
        if(n == 1 || n == 2)
            return 1;
        int result;
        result = fibo(n - 1) + fibo(n - 2);
        return result;
    }
}

class Shruti {
    public static void main(String args[]) {
        fib f = new fib();
        System.out.println(f.fibo(5));
        System.out.println(f.fibo(3));
        System.out.println(f.fibo(6));
    }
}
MrLore
  • 3,654
  • 2
  • 24
  • 36

0 Answers0