Problem
Test all odd numbers in the range from 233 to 241 for primality using the Miller-Rabin test with base 2.
Answer:
test n=233
- 233-1=2^3 * 29, thus k=3, q=29
- a^q mod n=2^29 mod 233=1
- test returns"inconclusive"(probably prime)
test n=235
- 235-1=2^1 * 117 ,thus k=1 q=117
- a^q mod n=2^117 mod 235=192
- 192!=1 and 192!=235-1
- test returns "composite"
test n=237
- 237-1=2^2 * 59, thus k=2, q=59
- a^q mod n=2^59 mod 237=167!=1
- 167!=237-1
- 167^2 mod 237=160!=237-1
- test returns "composite"
test n=239
- 239-1=2^1 * 119
- 2^119 mod 239=1
- test returns "inconclusive"(probably prime)
test n=241
- 241-1=2^4 *15
- 2^15 mod 241=233
- 233^2 mod 241=64
- 64^2 mod 241=240=241-1
- test returns "inconclusive"(probably prime)
问题思考
为什么237测试两遍就停了?为什么不继续往下平方测试
看K的值就知道了