votako

Fibonacci FINISH! EAH!

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