博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SICP习题 1.22(素数)
阅读量:4649 次
发布时间:2019-06-09

本文共 714 字,大约阅读时间需要 2 分钟。

(define (next-odd n)  (if (odd? n)      (+ 2 n)      (+ 1 n)))(define (smallest-divisor n)  (find-divisor n 2))(define (find-divisor n test-divisor)  (cond ((> (square test-divisor) n) n)        ((divides? n test-divisor) test-divisor)        (else (find-divisor n (+ test-divisor 1)))))(define (divides? a b)  (= (remainder a b) 0))(define (prime? n) (= n (smallest-divisor n)))(define (square x)  (* x x))(define (continue-primes n count)  (cond ((= count 0) (display "are primes"))        ((prime? n) (display n)        (newline)        (continue-primes (next-odd n) (- count 1)))        (else (continue-primes (next-odd n) count))))(continue-primes 1000 10)

  

转载于:https://www.cnblogs.com/R4mble/p/7892465.html

你可能感兴趣的文章
jsp 环境配置记录
查看>>
Python03
查看>>
LOJ 2537 「PKUWC2018」Minimax
查看>>
使用java中replaceAll方法替换字符串中的反斜杠
查看>>
Some configure
查看>>
流量调整和限流技术 【转载】
查看>>
1 线性空间
查看>>
VS不显示最近打开的项目
查看>>
MyEclipse安装Freemarker插件
查看>>
DP(动态规划)
查看>>
chkconfig
查看>>
pyQt 每日一练习 -- 登录框
查看>>
smartupload 上传文件时 把页面编码改成gbk 解决乱码
查看>>
EPS是什么格式
查看>>
Python的数据库操作(Sqlalchemy)
查看>>
2.抽取代码(BaseActivity)
查看>>
夏天过去了, 姥爷推荐几套来自smashingmagzine的超棒秋天主题壁纸
查看>>
反射的所有api
查看>>
css 定位及遮罩层小技巧
查看>>
项目中非常有用并且常见的ES6语法
查看>>