euler challenge 1 — python

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.

</pre>
x1 = 1
x2 = 1
tot = 1
result1 = 0
result2 = 0
resultMax = 0

while (tot &lt;= 100)
tot = x1 + x2
x1 = x2
x2 = tot
if (tot % 2 == 0):
if (tot &lt; 100):
print (tot)
result1 = tot
result2 = result1
resultMax = result1+result2
print (resultMax)
<pre>

Yang dibold, Hasilnya belum memuaskan šŸ˜€

Leave a comment