Created
December 25, 2009 00:20
-
-
Save offby1/263433 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang scheme | |
(require (planet soegaard/math/math)) | |
(define (max-sum limit) | |
(for*/fold ([max #f] | |
[old-a #f] | |
[old-b #f]) | |
([a (in-range limit)] | |
[b (in-range a)]) | |
(let ([this (apply + (digits (expt a b)))]) | |
(when (not max) | |
(set! max this)) | |
(if (< max this) | |
(values this a b) | |
(values max old-a old-b))))) | |
(max-sum 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment