euler-0.1.0.0

Safe HaskellSafe
LanguageHaskell2010

Euler.Util.FigurateNumbers

Contents

Description

Figurate numbers are sets of numbers related to polygon shapes.

Synopsis

Documentation

>>> import Test.QuickCheck
>>> import Data.List.Ordered (member, isSorted)

Triangle

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

All of the triangle numbers, ascending.

>>> take 5 triangles
[1,3,6,10,15]

triangleN :: Integral a => a -> a Source #

triangleN n is the nth triangle number.

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

isTriangle x denotes whether triangles contains x.

Properties

\(Positive n) -> isTriangle n == member n triangles
isSorted (take 100 triangles)

Pentagonal

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

All of the pentagonal numbers, ascending.

>>> take 10 pentagonals
[1,5,12,22,35,51,70,92,117,145]

pentagonalN :: Integral a => a -> a Source #

pentagonalN n is the nth pentagonal number.

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

isPentagonal x denotes whether pentagonals contains x.

Properties

\(Positive n) -> isPentagonal n == member n pentagonals
isSorted (take 100 pentagonals)

Hexagonal

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

All of the hexagonal numbers, ascending.

>>> take 5 hexagonals
[1,6,15,28,45]

hexagonalN :: Integral a => a -> a Source #

hexagonalN n is the nth hexagonal number.

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

isHexagonal x denotes whether hexagonals contains x.

Properties

\(Positive n) -> isHexagonal n == member n hexagonals
isSorted (take 100 hexagonals)