Showing posts with label ProjectEuler. Show all posts
Showing posts with label ProjectEuler. Show all posts

Wednesday, January 4, 2012

Write a Java code snippet to calculate the sum of the first 100 numbers in the Fibonacci sequence

Write a Java code snippet to calculate the sum of the first 100 numbers in the Fibonacci sequence

Fibonnaci numbers follow this rule:
  • F(0) = 0;
  • F(1) = 1;
  • F(n) = F(n-1) + F(n-2), n ≥ 2, n is integer
The first 10 numbers in the Fibonacci sequence are: 0, 1, 1*, 2, 3, 5, 8, 13, 21 and 34. Note that the number 1 appears twice in the sequence, by definition.

Here is my Java code snipet (as image and as text, so you can copy):