プロジェクト

全般

プロフィール

Problem 2 » 履歴 » リビジョン 2

リビジョン 1 (Noppi, 2023/12/27 01:31) → リビジョン 2/4 (Noppi, 2023/12/27 04:43)

[ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] 
 # [[Problem 2]] 

 ```scheme 
 #!r6rs 
 #!chezscheme 

 (import (chezscheme)) 

 (define answer-2 
   (let loop ([first 0] [second 1] [result 0]) ((first 0) (second 1) (result 0)) 
     (let ([next ((next (+ first second)]) second))) 
       (cond 
         [(< 4000000 next) result] 
         [(even? next) 
          (loop second next (+ result next))] 
         [else (loop second next result)])))) 

 (printf "2: ~D~%" answer-2) 
 ```