votako

Fib

Feb 7th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.27 KB | None | 0 0
  1. public class Test{
  2.  
  3.     static int fib(int n) {
  4.         if(n == 0) return 1;
  5.         if(n == 1) return 1;
  6.            
  7.         return fib(n - 1) + fib(n - 2);
  8.     }
  9.  
  10.     public static void main(String[] args) {
  11.         System.out.println(Test.fib(8));
  12.     }
  13.  
  14. }
Advertisement
Add Comment
Please, Sign In to add comment