Skip to content

Instantly share code, notes, and snippets.

@shirok
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirok/9d271de7c59292a45a11 to your computer and use it in GitHub Desktop.
Save shirok/9d271de7c59292a45a11 to your computer and use it in GitHub Desktop.
(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