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

Solutions.P31

Description

Some solutions to Problems.P31 of Ninety-Nine Haskell Problems.

Synopsis

Documentation

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

Determine whether a given integer number is prime.

Checks whether the integer is even or if there is a divisor among odd integers not greater than its square root.

isPrime' :: Integral a => a -> Bool Source #

Determine whether a given integer number is prime.

Uses an Erastothenes sieve to construct a list of primes up to at least the square root of the integer, and searches for a divisor among them.

isPrime'' :: Integral a => a -> Bool Source #

Determine whether a given integer number is prime.

From a list of all prime numbers, search for a divisor.