I launched Project Euler. I am on problem 2 and came up with this code to come up with even a Fibonacci amount of up to 4 million. The code seems to do pretty much what I want. I see the correct amount indicated when running the code. The only part that I really confuse is the most recent number displayed in the results. Here is what he shows:
JS CODE:
var previous = 0; var current = 1; var sum = 0; var next; for(i = 1; i < 100; i++){ next = current + previous; previous = current; current = next; if(current % 2 === 0 && current < 4000000) { sum += current; console.log(sum); } }
Results:
2 10 44 188 798 3382 14328 60696 257114 1089154 4613732 (this is the number i was trying to get) => 354224848179262000000 (confused as to why this number shows up and what it represents)
source share