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.
-피보나치 설명 블라블라
- Generate 2 value A,B
-A,B는 매번 새 값 넣어줘야함 (전값,더한값)
- A<=4,000,000
항 자체가 숫자넘지않도록
(bellow는 미만이지만 do not exceed는 이하 )
- if A%2==0
-B가아닌 A를 검토하고 더하는이유: 어차피 B값은 A값으로 대입하게 되있으니깐
A,B,even_sum=1,2,0
while A<=4000000 :
if A%2==0:
even_sum+=A
A,B=B,A+B
쉬워그런지 성취감있구먼
'Math🥸 > Project Euler' 카테고리의 다른 글
4. Largest Palindrome Product (0) | 2024.12.08 |
---|---|
3. Largest Prime Factor (0) | 2024.11.12 |
1. Multiples of 3 or 5 (0) | 2024.11.07 |