


If not, also great. Either way, please help yourselves and don't leave me with leftovers =)
Know a company who may want to sponsor food for future talks? Talk to me after
Who you are...Where your from...
Describe your Experience with Ethereum, Smart Contracts, Blockchain, BitCoin or life in general...
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
//generates a fib sequence who's value is < n;
//adopted from https://gist.github.com/jfairbank/8d36e4bde9c16dc0bac7
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || current < n) {
yield current;
[current, next] = [next, current + next];
}
}
let [...fibseq] = fibonacci(4000000);
//fibseq = (34) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584,
//4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040,
//1346269, 2178309, 3524578]
let sum = 0;
fibseq.forEach(item => {
if(item % 2 == 0) {
sum += item;
}
});
//sum = 4613732
Sego Solutions & ADC Medical Devices
LI Drupal Meetup
Stack Starter
All Around Awesome Guy