Skip to content

Commit

Permalink
[Int] add is-prime and expmod
Browse files Browse the repository at this point in the history
  • Loading branch information
felher committed Sep 20, 2012
1 parent 162131a commit a6f3177
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/Int.pod
Expand Up @@ -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.