Testing a nontrivial (ends in 1, 3, 7, 9) composite and a prime in each range.
()
| 88 | |
| 89 | |
| 90 | def test_miller_rabin() -> None: |
| 91 | """Testing a nontrivial (ends in 1, 3, 7, 9) composite |
| 92 | and a prime in each range. |
| 93 | """ |
| 94 | assert not miller_rabin(561) |
| 95 | assert miller_rabin(563) |
| 96 | # 2047 |
| 97 | |
| 98 | assert not miller_rabin(838_201) |
| 99 | assert miller_rabin(838_207) |
| 100 | # 1_373_653 |
| 101 | |
| 102 | assert not miller_rabin(17_316_001) |
| 103 | assert miller_rabin(17_316_017) |
| 104 | # 25_326_001 |
| 105 | |
| 106 | assert not miller_rabin(3_078_386_641) |
| 107 | assert miller_rabin(3_078_386_653) |
| 108 | # 3_215_031_751 |
| 109 | |
| 110 | assert not miller_rabin(1_713_045_574_801) |
| 111 | assert miller_rabin(1_713_045_574_819) |
| 112 | # 2_152_302_898_747 |
| 113 | |
| 114 | assert not miller_rabin(2_779_799_728_307) |
| 115 | assert miller_rabin(2_779_799_728_327) |
| 116 | # 3_474_749_660_383 |
| 117 | |
| 118 | assert not miller_rabin(113_850_023_909_441) |
| 119 | assert miller_rabin(113_850_023_909_527) |
| 120 | # 341_550_071_728_321 |
| 121 | |
| 122 | assert not miller_rabin(1_275_041_018_848_804_351) |
| 123 | assert miller_rabin(1_275_041_018_848_804_391) |
| 124 | # 3_825_123_056_546_413_051 |
| 125 | |
| 126 | assert not miller_rabin(79_666_464_458_507_787_791_867) |
| 127 | assert miller_rabin(79_666_464_458_507_787_791_951) |
| 128 | # 318_665_857_834_031_151_167_461 |
| 129 | |
| 130 | assert not miller_rabin(552_840_677_446_647_897_660_333) |
| 131 | assert miller_rabin(552_840_677_446_647_897_660_359) |
| 132 | # 3_317_044_064_679_887_385_961_981 |
| 133 | # upper limit for probabilistic test |
| 134 | |
| 135 | |
| 136 | if __name__ == "__main__": |
no test coverage detected