Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Figurate numbers are sets of numbers related to polygon shapes.
Synopsis
- triangles :: Integral a => [a]
- triangleN :: Integral a => a -> a
- isTriangle :: Integral a => a -> Bool
- pentagonals :: Integral a => [a]
- pentagonalN :: Integral a => a -> a
- isPentagonal :: Integral a => a -> Bool
- hexagonals :: Integral a => [a]
- hexagonalN :: Integral a => a -> a
- isHexagonal :: Integral a => a -> Bool
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]
isTriangle :: Integral a => a -> Bool Source #
denotes whether isTriangle
xtriangles
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 #
is the nth pentagonal number.pentagonalN
n
isPentagonal :: Integral a => a -> Bool Source #
denotes whether isPentagonal
xpentagonals
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 #
is the nth hexagonal number.hexagonalN
n
isHexagonal :: Integral a => a -> Bool Source #
denotes whether isHexagonal
xhexagonals
contains x
.
Properties
\(Positive n) -> isHexagonal n == member n hexagonals
isSorted (take 100 hexagonals)