ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Solutions.Arithmetic

Description

These functions were written in support of specific arithmetic problems, but which turn out to be useful for other problems as well.

Synopsis

Documentation

dividesBy :: Integral a => a -> a -> Bool Source #

Whether the first argument divides by the second argument.

Initially written to support Problems.P31.

primes :: Integral a => [a] Source #

List of all prime numbers.

Computed with an Erastothenes sieve. Unlike the classic sieve, which strikes out multiples of prime numbers from subsequent numbers, checks the primality of each integer against the prime numbers already determined.

Initially written to support Problems.P31.

gaussianUnits :: [Complex Integer] Source #

List of Gaussian integer units. I.e., \(1\), \(i\), \(-1\), and \(-i\).

gaussianAdd :: Complex Integer -> Complex Integer -> Complex Integer Source #

Add two Gaussian integers.

gaussianMultiply :: Complex Integer -> Complex Integer -> Complex Integer Source #

Multiply two Gaussian integers.