Advertisement
tolfasn

fibEven

Nov 9th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package fibeven;
  2. public class FibEven {
  3.   public static long fibonacci(long number) {
  4.     if ((number == 0) || (number == 1))
  5.       return number;
  6.     else
  7.      
  8.       return fibonacci(number - 1) + fibonacci(number - 2);
  9.   }
  10.  
  11.   public static void main(String[] args) {
  12.      
  13.       long sum = 0;
  14.      
  15.     for (int counter = 1; counter <= 33; counter++){
  16.         if (fibonacci(counter) % 2 != 0) {
  17.           } else {
  18.             sum = sum + fibonacci(counter);
  19.           }
  20.     }
  21.     System.out.println(sum);
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement