-
Notifications
You must be signed in to change notification settings - Fork 6
Prime
Rugen Heidbuchel edited this page Apr 30, 2015
·
4 revisions
Almost all prime functions are totally generic, so you can use them with every type that adopts the desired protocols. Off course all basic types like Int, UInt, Double, ... are already implemented, but you can create your own type and adopt the protocols to make use of these prime functions as well.
The functions that are not generic yet will be converted.
Returns whether the given number is prime.
protocols to adopt:
Returns whether the given numbers are coprime. This means their greatest common divisor equals 1.
protocols to adopt:
- Equatable
- Modulable
- IntegerLiteralConvertible
Returns the primes to (and including) the given integer.
Returns the prime factors of the given integer in ascending order. Prime factors with a higher multiplicity will appear multiple times.