Last active
August 29, 2015 14:14
-
-
Save shirok/9d271de7c59292a45a11 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
(use gauche.sequence) | |
(use gauche.lazy) | |
(use math.prime) | |
(use srfi-1) | |
(define-constant *bound* (- (expt 2 31) 1)) | |
(define (solve) | |
(let* ([reverse-primes (reverse! (take-while (^p (<= p *bound*)) *primes*))] | |
[total (length reverse-primes)]) | |
(find (^p (bpsw-prime? (cdr p))) | |
(lmap cons reverse-primes (liota total (- total 1) -1))))) | |
#| | |
実行例 | |
gosh> (time (solve)) | |
;(time (solve)) | |
; real 124.610 | |
; user 132.010 | |
; sys 2.170 | |
(2147483579 . 105097561) | |
|# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment