Created
September 2, 2013 20:12
-
-
Save carl-eastlund/6416843 to your computer and use it in GitHub Desktop.
Attempting to reproduce a hash-iterate-key bug using hash tables directly rather than sets.
This file contains hidden or 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 racket | |
| (require math/number-theory) | |
| (define limit 28123) | |
| (define (is-abundant? n) | |
| (> (- (apply + (divisors n)) n) n)) | |
| (define abundants | |
| (for/hash ([i (in-range limit)] | |
| #:when (is-abundant? i)) | |
| (values i #t))) | |
| (define abundants-gen | |
| (for*/hash ([i (in-hash-keys abundants)] | |
| [j (in-hash-keys abundants)] | |
| #:when (and (not (= i j)) (< (+ i j) limit))) | |
| (values (+ i j) #t))) | |
| (hash-count abundants-gen) | |
| abundants-gen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment