灯下 登录
计算机科学 / SICP / 1.2.6 Example: Testing for Primality

Exercise 1.24 · 习题

Exercise 1.24: Modify the

timed-prime-test procedure of Exercise 1.22 to use

fast-prime? (the Fermat method), and test each of the 12 primes you

found in that exercise. Since the Fermat test has Θ

(

log

n

)

growth, how would you expect the time to test primes near 1,000,000 to

compare with the time needed to test primes near 1000? Do your data bear this

out? Can you explain any discrepancy you find?

练习 1.24:将练习 1.22 的 timed-prime-test 过程修改为使用 fast-prime?(费马方法),并对该练习中找到的 12 个素数进行检验。由于费马检验的增长阶为 Θ(log n),你预期检验 1,000,000 附近素数所需时间与检验 1000 附近素数所需时间相比如何?你的数据是否支持这一预期?你能解释所发现的任何差异吗?