きったんの頭

#! /usr/bin/env python3
"""
pe2.py
https://mind.kittttttan.info/py/pe2.html
"""

def pe2(limit=4000000):
    """
    By considering the terms in the Fibonacci sequence
    whose values do not exceed four million,
    find the sum of the even-valued terms.
    """
    a,b,s = 1,2,2
    while b <= limit:
        a, b = b, a + b
        if not b & 1:
            s += b
    print(s)

if __name__ == "__main__":
    pe2()