:nth-child an+b Pattern Index Generator

List positive child indices up to a supplied bound matching a*n+b for integer n at least zero, supporting negative and zero a; exact integer arithmetic avoids overflow.

Description

The nth-child An+B pattern identifies positive sibling positions produced by a×n+b for integers n starting at zero.

The nth-child An+B pattern identifies positive sibling positions produced by a×n+b for integers n starting at zero. A negative a can describe a finite prefix, while a zero a can select just one position.1

List positive child indices up to a supplied bound matching a*n+b for integer n at least zero, supporting negative and zero a; exact integer arithmetic avoids overflow.

When to use :nth-child an+b Pattern Index Generator

Use this tool to list positive child indices up to a supplied bound matching a*n+b for integer n at least zero, supporting negative and zero a; exact integer arithmetic avoids overflow.

Choose the CSS values, dimensions or counts for this calculation. Supply resolved numeric measurements in matching units and the explicit reference box or writing mode where required.

How to use :nth-child an+b Pattern Index Generator and understand its results

  1. Choose the CSS values, dimensions or counts for this calculation. Supply resolved numeric measurements in matching units and the explicit reference box or writing mode where required.
  2. Enter a, b, limit using the field table and calculation rules, then run the tool.
  3. Read indices. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
aAinteger; minimum: -9007199254740991; maximum: 9007199254740991Required
bBinteger; minimum: -9007199254740991; maximum: 9007199254740991Required
limitLimitinteger; minimum: 1; maximum: 100000Required

Enter signed safe-integer a and b and a positive limit no greater than 100,000. The tool checks each index from 1 through limit using exact integer subtraction and division, returning matching indices in ascending order. Negative and zero a are supported, as are negative b values; only positive child positions are emitted.

match i if a = 0 and i = b, or (i − b) is divisible by a with (i − b)/a ≥ 0

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
indicesIndiceslist of integer; minimum: 1
json
{
  "input": {
    "a": 2,
    "b": 1,
    "limit": 7
  },
  "output": {
    "indices": [
      1,
      3,
      5,
      7
    ]
  }
}

Limitations and assumptions

It receives numeric coefficients rather than parsing an nth-child expression. The limit bounds enumeration and does not represent a queried DOM length automatically. It does not apply selector filters or count actual siblings.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use :nth-child Zebra Odd/Even Classifier: Classify a one-based child index for the odd and even nth-child selectors. For a complementary task, use Keyframe Percent Even Split Calculator: Generate evenly spaced keyframe percentages including 0 and 100 from a count of at least two, returning full number precision and limiting materialization to 10,000 offsets.

References

  1. :nth-child an+b Pattern Index Generator — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies