Guest User

Untitled

a guest
Jun 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. //Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
  2. //every third Fibonacci number is even
  3.  
  4. public void sumFibbonaci2() {
  5. long a, b, c;
  6. long sum = 0;
  7. a = b = 1;
  8. c = a + b;
  9. while (c < limit) {
  10. sum += c;
  11. a = b + c;
  12. b = c + a;
  13. c = a + b;
  14. }
  15. System.out.println(sum);
  16. }
Add Comment
Please, Sign In to add comment