factory-0.3.0.0: Rational arithmetic in an irrational world.

Factory.Math.PerfectPower

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Exports functions related to perfect powers.

Synopsis

# Functions

maybeSquareNumber :: Integral i => i -> Maybe i Source #

• Returns (Just . sqrt) if the specified integer is a square number (AKA perfect square).
• https://en.wikipedia.org/wiki/Square_number.
• http://mathworld.wolfram.com/SquareNumber.html.
• (Math.Power.square . sqrt) is expensive, so the modulus of the operand is tested first, in an attempt to prove it isn't a perfect square. The set of tests, and the valid moduli within each test, are ordered to maximize the rate of failure-detection.

## Predicates

isPerfectPower :: Integral i => i -> Bool Source #