PolygonalNumbers
The -gonal figurate numbers , one lazy indexed collection per polygon size .
PolygonalNumbers(k) for , the -gonal numbers.Typed signatures
| Type | Package | Applies |
|---|---|---|
(integer<0..>) -> indexed_collection<integer> | combinatorics | always |
Details
- A lazy indexed family for each : , and unranks in closed form -- .
- reproduce TriangularNumbers, SquareNumbers, PentagonalNumbers, HexagonalNumbers, HeptagonalNumbers and OctagonalNumbers termwise; those fixed- names exist as their own lazy collections for convenience, not as a separate definition.
- Membership goes through Element by inverting the quadratic in exactly for the given -- is true, is false.
Definition
Epsil, as the implementation runs it.
count(_k)
0 if _k < 3 else PositiveInfinityunrank(_k, _r)
(_r + 1) * ((_k - 2) * (_r + 1) - (_k - 4)) / 2rank(_k, _x)
Apply(
(sq_at: integer) => sq_at if (sq_at + 1) * ((_k - 2) * (sq_at + 1) - (_k -
4)) /
2 == _x else -1,
Fold(
Function(
sq_at + 2 ^ sq_b if (sq_at + 2 ^ sq_b + 1) *
((_k - 2) * (sq_at + 2 ^ sq_b + 1) -
(_k - 4)) / 2 <= _x else sq_at,
sq_at,
sq_b,
),
0,
Range(Floor(Log(_x, 2)) + 1, 0, -1),
),
) if _k >= 3 else -1valid(_k, _x)
Apply(
(sq_at: integer) => (sq_at + 1) * ((_k - 2) * (sq_at + 1) - (_k - 4)) / 2 ==
_x,
Fold(
Function(
sq_at + 2 ^ sq_b if (sq_at + 2 ^ sq_b + 1) *
((_k - 2) * (sq_at + 2 ^ sq_b + 1) -
(_k - 4)) / 2 <= _x else sq_at,
sq_at,
sq_b,
),
0,
Range(Floor(Log(_x, 2)) + 1, 0, -1),
),
) if _k >= 3 && _x >= 1 else FalseEnumeration
Examples
7 more kept as data, checked against the oraclesAbout
| Examples | 7 |
|---|
Implementation
mapped
wolframpackages/oracle/src/mappings.tsWolfram's own PolygonalNumber[r, n] gives one term (kernel-verified: matches ours termwise) but there's no lazy collection to Take from -- only Table[PolygonalNumber[r, n], {n, 1, count}], which a per-head template on PolygonalNumbers alone can't compose with the outer Take call. Wolfram Function Repository searched; PolygonalDiagram found but it's a visualization (draws the dot array), not a term source.
See also: TriangularNumbers, SquareNumbers, PentagonalNumbers, HexagonalNumbers, Count, At, Element