Skip to content
Browse files

[Int] add is-prime and expmod

  • Loading branch information...
1 parent 162131a commit a6f31779247a33450ee7ef3db989a19a61a59dff @felher felher committed
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/Int.pod
View
19 lib/Int.pod
@@ -35,4 +35,23 @@ codepoint number and converting it the corresponding character.
Does an integer division, rounded down.
+=head2 expmod
+
+ multi sub expmod (Int:D: Int $y, Int $mod) returns Int:D
+ multi method expmod (Int:D: Int $y, Int $mod) returns Int:D
+
+Returns the given C<Int> raised to the C<$y> power within modulus C<$mod>.
+
+=head2 is-prime
+
+ multi sub is-prime (Int:D: Int $tries = 100) returns Bool:D
+ multi method is-prime (Int:D: Int $tries = 100) returns Bool:D
+
+Returns C<True> if this C<Int> is known to be a prime, or is likely to be a
+prime based on a probabalistic Miller-Rabin test. C<$tries> is the maximal
+number of iterations the test is allowed to do.
+
+Returns C<False> if this C<Int> is known not to be a prime, or is unlikely to be
+a prime after probabalistic testing.
+
=end pod

0 comments on commit a6f3177

Please sign in to comment.
Something went wrong with that request. Please try again.