NumberTheory is a Swift Package Manager package for iOS/tvOS (10.0 and above), watchOS (4.0 and above), and macOS (10.14 and above), under Swift 5.0 and above, defining a few simple functions to perform common number-theoretic operations:
/// Greatest common divisor
public func gcd<T: SignedInteger>(_ a: T, _ b: T) -> T?
public func gcd<T: SignedInteger>(_ values: [T]) -> T?
/// Least common multiple
public func lcm<T: SignedInteger>(_ a: T, _ b: T) -> T?
public func lcm<T: SignedInteger>(_ values: [T]) -> T?
public extension BinaryInteger {
var isEven: Bool
var isOdd: Bool
}NumberTheory is provided only as a Swift Package Manager package, because I'm moving away from CocoaPods and Carthage, and can be easily installed directly from Xcode.
NumberTheory is available under the MIT license. See the LICENSE file for more info.