Skip to content

Instantly share code, notes, and snippets.

@offby1
Created December 25, 2009 00:20
Show Gist options
  • Save offby1/263433 to your computer and use it in GitHub Desktop.
Save offby1/263433 to your computer and use it in GitHub Desktop.
#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