Permalink
Browse files

Add deterministic shortcut rules for numbers less than 341,550,071,72…

…8,321.
  • Loading branch information...
1 parent 8e3a364 commit 27543db1f12b43fd6581bd05af27678dbf69adce @colomon colomon committed Sep 22, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/CORE.setting
View
@@ -3871,7 +3871,13 @@ sub is-prime($candidate, $tries = 100) {
when 2 | 3 | 5 | 7 | 11 { return True; }
when * < 2 { return False; }
when * %% 2 { return False; }
- @a = (2 ..^ $n).pick($k);
+ when * < 1_373_653 { @a = 2, 3; }
+ when * < 9_080_191 { @a = 31, 73; }
+ when * < 4_759_123_141 { @a = 2, 7, 61; }
+ when * < 2_152_302_898_747 { @a = 2, 3, 5, 7, 11; }
+ when * < 3_474_749_660_383 { @a = 2, 3, 5, 7, 11, 13; }
+ when * < 341_550_071_728_321 { @a = 2, 3, 5, 7, 11, 13, 17; }
+ default { @a = (2 ..^ $n).pick($k); }
}
my Int $d = $n - 1;

0 comments on commit 27543db

Please sign in to comment.