Recent Posts
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Today
Total
관리 메뉴

Try

[ProjectEuler] 프로젝트 오일러 Problem 2 본문

Algorithm/ProjectEuler

[ProjectEuler] 프로젝트 오일러 Problem 2

HAS3ONG 2019. 6. 28. 00:42
ans = 2

a = 1
b = 2
c = 0
while 1:
    if c > 4000000:
        break

    c = a + b
    a = b
    b = c

    if c % 2 == 0:
        ans += c

print(ans)

출처

http://euler.synap.co.kr/prob_detail.php?id=2

Comments