## Sum Even Fibonacci Numbers

* Write a func named SumEvenFibonacci that takes a parameter of type int and returns a value of type int

* Generate all of the Fibonacci numbers starting with 1 and 2 and ending on the highest number before exceeding the parameter's value 


#### Each new number in the Fibonacci sequence is generated by adding the previous two numbers - by starting with 1 and 2(the input could be smaller), the first 10 numbers will be:


```
 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
```

* Sum all of the even numbers you generate and return that int

#### Example:

```
sumEvenFibonacci(8) // returns 10 by adding the even values 2 and 8
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def SumEvenFibonacci(limit):
	

Solutions:
def SumEvenFibonacci(limit):
	(a, b, s) = (1, 1, 0)
	while a <= limit:
		if not a % 2:
			s += a
		(a, b) = (b, a + b)
	return s


def SumEvenFibonacci(limit):
	(a, b, result) = (1, 2, 0)
	while b <= limit:
		if b % 2 == 0:
			result += b
		(a, b) = (b, a + b)
	return result


from functools import lru_cache
from itertools import takewhile, count
even_fib = lru_cache(maxsize=None)(lambda n: 2 if n == 0 else 8 if n == 1 else 4 * even_fib(n - 1) + even_fib(n - 2))

def SumEvenFibonacci(limit):
	return sum(takewhile(limit.__ge__, map(even_fib, count())))


def sum_even_fibonacci(limit):
	if limit < 2:
		return 0
	(a, b, total) = (1, 2, 0)
	while b <= limit:
		total += b % 2 == 0 and b
		(a, b) = (b, a + b)
	return total
SumEvenFibonacci = sum_even_fibonacci


def SumEvenFibonacci(limit):
	lst = []
	for num in fib(limit):
		if num > limit:
			break
		if num % 2 == 0:
			lst.append(num)
	return sum(lst)

def fib(num):
	(a, b) = (1, 2)
	while True:
		yield a
		(a, b) = (b, a + b)


def SumEvenFibonacci(n):
	(a, b, r) = (1, 1, 0)
	while a <= n:
		(a, b, r) = (b, a + b, r + (a & 1 < 1) * a)
	return r


def fibonacci(max):
	(a, b) = (1, 2)
	while a <= max:
		yield a
		(a, b) = (b, a + b)

def SumEvenFibonacci(limit):
	return sum((n for n in fibonacci(limit) if n % 2 == 0))


from functools import reduce

def fib(n):
	array = []
	(a, b) = (0, 1)
	while a < n + 1:
		array.append(a)
		(a, b) = (b, a + b)
	return array

def SumEvenFibonacci(limit):
	array = fib(limit)
	resultado = list(filter(lambda x: x % 2 == 0, array))
	return reduce(lambda x, y: x + y, resultado)


def SumEvenFibonacci(n):
	(s, a, b) = (0, 1, 2)
	while b <= n:
		(a, b, s) = (b, a + b, s + (1 - b % 2) * b)
	return s