Loading [MathJax]/extensions/tex2jax.js

2010年7月20日火曜日

Goldbach's conjecture

;; P40 (**) Goldbach's conjecture.
;; Goldbach's conjecture says that every positive even number greater than 2 is the sum of two prime numbers. Example: 28 = 5 + 23. It is one of the most famous facts in number theory that has not been proved to be correct in the general case. It has been numerically confirmed up to very large numbers (much larger than we can go with our Prolog system). Write a predicate to find the two prime numbers that sum up to a given even integer.
;; Example:
;; * (goldbach 28)
;; (5 23)
#lang racket
(provide goldbach)
(require "p39.ss")
(define (goldbach n)
(and (> n 2) (even? n)
(let loop ((lst (eratosthenes n)))
(let ((i (car lst)))
(let ((j (- n i)))
(if (member j lst)
`(,i ,j)
(loop (cdr lst))))))))
view raw p40.ss hosted with ❤ by GitHub

1 件のコメント:

  1. Casino Rewards - Goo Millions
    You can find the latest Casino 오락실 슬롯 머신 게임 Rewards 넷마블 토토 사이트 casino rewards 벳 365 우회 접속 in the app. betting From a welcome bonus w88 코리아 to $50 free spins, you'll get 100%

    返信削除