Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
- //every third Fibonacci number is even
- public void sumFibbonaci2() {
- long a, b, c;
- long sum = 0;
- a = b = 1;
- c = a + b;
- while (c < limit) {
- sum += c;
- a = b + c;
- b = c + a;
- c = a + b;
- }
- System.out.println(sum);
- }
Add Comment
Please, Sign In to add comment