SquareNumbers
The perfect squares as a lazy indexed collection, unranked by position.
SquareNumbersthe squares for , an infinite indexed collection.Details
- A lazy indexed collection: , and unranks in closed form -- .
- OEIS A000290.
- Membership goes through Element: is true, is false.
Definition
Epsil, as the implementation runs it.
count()
PositiveInfinityunrank(_r)
(_r + 1) * (_r + 1)rank(_x)
Apply(
(sq_at: integer) => sq_at if (sq_at + 1) * (sq_at + 1) == _x else -1,
Fold(Function(
sq_at + 2 ^ sq_b if (sq_at + 2 ^ sq_b + 1) *
(sq_at + 2 ^ sq_b + 1) <= _x else sq_at,
sq_at,
sq_b,
), 0, Range(Floor(Log(_x, 2)) + 1, 0, -1)),
) if True else -1valid(_x)
Apply(
(sq_at: integer) => (sq_at + 1) * (sq_at + 1) == _x,
Fold(Function(
sq_at + 2 ^ sq_b if (sq_at + 2 ^ sq_b + 1) *
(sq_at + 2 ^ sq_b + 1) <= _x else sq_at,
sq_at,
sq_b,
), 0, Range(Floor(Log(_x, 2)) + 1, 0, -1)),
) if True && _x >= 1 else FalseEnumeration
Examples
About
| Examples | 1 |
|---|---|
| Crosswalk | OEISWolfram Languagemathlib4 |
See also: Count, At, Element, PrimeNumbers, AbundantNumbers