Comments

Saturday, November 26, 2011

Java Problem Set 2

Posted by on Saturday, November 26, 2011 Read our previous post
Write a function which calculates the sum of even Fibonacci numbers.

public static void main(String args[]) {
    for(int i=1;i<22;i++)
        System.out.print(sumofEvenFibonacci(i) + " ");
}

public static long sumofEvenFibonacci(int n) {
    // add your code here.
    return sum;
}

prints

0 0 2 2 2 10 10 10 44 44 44 188 188 188 798 798 798 3382 3382 3382 14328



-->
--> [Click for sample solution]

© 2010 Code 2 Learn