prime-test

secje posted @ 2010年5月10日 10:22 in sicp , 777 阅读

 

(define (square x) (* x x))
(define (fast-prime? n times)
  (define (expmod base exp m)
    (cond ((= exp 0) 1)
          ((even? exp)
           (remainder (square (expmod base (/ exp 2) m))
                      m))
          (else
           (remainder (* (remainder base m) (expmod base (- exp 1) m))
                    m))))
  (define (fermat-test n)
    (define (try-it a)
      (= (expmod a n n) a))
    (try-it (+ 1 (random (- n 1)))))
  (cond ((= times 0) true)
        ((fermat-test n) (fast-prime? n (- times 1)))
        (else false)))

PLT不认random,改用MIT Scheme了,看来要加快emacs的脚步了,越到后面谁知道还会发生什么,现在就是蛋疼的用PLT当编辑器和调试器,edwin做解释器

 

 

cleaning services 说:
2019年10月24日 02:18

Some sort of Maid Service company usually possesses many staff members that do the job in competitors. Some on the companies usually are franchises that are fitted with specially formulated products in addition to equipment to help professionally clean your own home in a environmentally-friendly technique. Companies provide simple schedule, dependable cleaning that's usually bonded in addition to insured.

northbamarealestate 说:
2020年4月19日 23:41

Quite a few investors are put off by real estate investment because they can't have any time or inclination to be landlords in addition to property operators, both which are in fact, a vocation in independently. If this investor is usually a rehabber or maybe wholesaler, real estate investment becomes more of any business as an alternative to an investment decision.

atlantablackbusiness 说:
2020年4月19日 23:42

This company model runs by applying commission structured salespersons to help earn revenue by both equally selling merchandise and by means of enrolling people in downline, a organisation connected with recruits, recruits recruits and many others.

freezebusinessrates 说:
2020年4月19日 23:42

Has your online business ever experienced a period of time when gross sales were decrease, sluggish as well as even not for existent for time? Most businesses are there formerly or a different, some caused by predictable small business cycles and many due to help unexpected functions.

shawcorsuccess 说:
2020年4月19日 23:42

Assemble and Encourage Relationships. Gourmet coffee is low cost. Get available and discuss with colleagues in addition to previous clients to express business, their small business - but remind them that you'll be a component of their small business network, when i. e. friends helping friends. An relaxed 45 small meeting spanning a cup of joe focused on their business will probably always bring you a minimum of one good idea you should utilize. Maybe even a referral.

riverbankmarketing 说:
2020年4月19日 23:43

Current marketing is usually an expansive subject, and it offers everything by digital marketing online to regular offline advertising and marketing. Business entrepreneurs rarely have enough time to know different advertising and marketing techniques and understand how to implement these individuals well on their platforms.

maids in dubai 说:
2020年5月05日 01:01

Cleaning service of reverance wedding speeches generally is a tricky for getting right. For the reason that maid connected with honor, also you can find bit of time to expend preparing this speech amongst all of those other wedding preparations. In the tip, though, will probably be worth your time, as this can be a privilege so that you can speak on the part of the bride whilst your best pal.

painters in Dubai 说:
2020年5月05日 01:02

At present before flowing out to rent the most beneficial exterior house hold painters around, be some cautious considering their professionalism and trust and proficiency mean hi-def come economical. Try so you can get as a number of quotations as is feasible from competent painters and check with each the level of paint can be required, what ones own charges can be and how many years it should take them for you to complete painting your place.

maid services dubai 说:
2021年6月07日 21:37

Don masks along with gloves when you find yourself cleaning your own home. Make sure the wearables are generally either throw-aways or reusable. Wipe most-touched surfaces including tables, challenging chairs, home counters, lavatories, doorknobs, rural controls along with light knobs. You will use dedicated cleanup agents using water as well as sprays for the children.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter