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.

 

피보나치 순열에서 새 항은 이전 두 항을 합해서 구해진다. 1과 2로 시작하면 첫 10개 항은 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...가 된다.

피보나치 순열에서 4백만이 넘지 않는 항 중 짝수인 항의 합계를 구하시오.

--------------------------------------------------------------------------

 

피보나치 순열 새 항의 값이 4백만 이하인 동안, 짝수인 항을 더해서 답을 구하면 된다. 변수 4개로 답을 구하는 것이 더 간단하지만, 리스트를 활용해서 답을 구했다.

 

+ Recent posts