fork download
  1. (define (solve)
  2. (define (step n k)
  3. (cond ((= n 3) k)
  4. ((even? n) (step (/ n 2) (+ 1 k)))
  5. (else (step (* 3 (+ 1 n)) (+ 1 k)))))
  6. (define (max-step m n)
  7. (if (zero? n) m
  8. (let ((s (step n 0)))
  9. (max-step
  10. (if (< (car m) s) (cons s n) m)
  11. (- n 1)))))
  12. (max-step (cons 0 0) 10000)
  13. )
  14.  
  15. (display "(step . n) = ")
  16. (display (solve))
  17. (newline)
  18.  
Success #stdin #stdout 0.5s 4408KB
stdin
Standard input is empty
stdout
(step . n) = (239 . 7421)