Arbitrary-precision arithmetic 2026-10-20
Integer arithmetic in which storage grows with the number of numerical digits needed, instead of imposing a fixed word size. It allows exact addition, multiplication, and exponentiation on large integers, subject to available memory; operation costs grow with operand length.
Balanced number 2026-10-20
A positive integer whose first decimal numerical digits have the same sum as its last digits, where is the number of digits. For odd , the shared middle digit cancels from the equality. Counts and value sums can therefore be assembled from two half-length digit dynamic programming tables indexed by base-p digit sum.
Binary palindrome 2026-10-20
A palindromic number in binary representation, with no leading zeros. Every positive binary palindrome is an odd number, because its first and last numerical digits must both be one.
Bouncy number 2026-10-20
A positive integer whose sequence of numerical digits is neither weakly increasing nor weakly decreasing from left to right. Equivalently, one adjacent pair strictly rises and another strictly falls. Numbers in both monotone families have all digits equal, so their overlap consists of the repdigits.
Circular prime 2026-10-20
A prime number for which every cyclic rotation of its numerical digits is also a prime number. In decimal representation, is an example because are all prime numbers. A multi-digit circular prime can contain only : any other digit can be rotated into the units position and force divisibility by or .
Decimal digit 2026-10-20
Digital root 2026-10-20
Repeatedly sum the numerical digits of a nonnegative integer in base until a single numerical digit remains. For , the result is , while the result for zero is zero. This follows because , so summing numerical digits preserves the integer congruence class modulo .
Digit dynamic programming 2026-10-20
Count or sum integers by processing their numerical digits and merging prefixes that have the same possible continuations. Typical state records include the current position, whether the prefix still equals an upper limit, a remainder, or a bit mask of digits already used. The final answer comes from accepting exactly those states satisfying the desired digit constraints.
Digit permutation 2026-10-20
A rearrangement of the numerical digits of a numeral. Two numerals have the same digit permutation class exactly when their digit multisets agree. If they represent numbers of the same length, a leading zero must be disallowed.
Digit sum 2026-10-20
The digit sum of a nonnegative integer in a given base is the sum of its numerical digits. In base , replacing each power by shows that the integer and its digit sum are congruent modulo .
Least-significant-digit radix sort 2026-10-18
A least-significant-digit radix sort processes numerical digits from smallest to largest place value. Fix integers and , and take complete sorting records whose sort keys satisfy . Use exactly positions in positional notation with radix , including leading zeros. At pass , apply a stable digit sort to the current array usingThe floor function selects the integer quotient, and the remainder selects the current numerical digit. Move the complete sorting record, including its associated data. There are exactly passes, so this procedure terminates even for an empty array. The radix sort suffix invariant supplies its algorithm correctness argument.
For an original input, let the letters identify the attached data:Here , , and leading zeros only align place values; represents the integer five. The exact pass ledger is:After the units pass, the numerical digits are . The ties retain before and before before . This array is not yet ordered by its whole integer sort keys: still precedes . After the tens pass, the two-position suffixes are . In particular, now precedes : their tens numerical digits differ, so stable sorting does not require retaining their previous order. The hundreds pass produces the final sorted array, with all attached letters preserved.
Three stable digit passes order successively longer suffixes
. Original decimal radix sort ledger. Each card carries an unchanged record label. Orange marks the numerical digit read in the current pass; green marks lower positions already processed. The suffix row beneath each pass shows precisely what is ordered, rather than claiming whole-key sortedness early. Details. Numeral 2026-10-14
Numerical digit Created 2026-10-14 Updated 2026-10-20
A numerical digit is one symbol in a positional notation string, denoting an integer from zero through one less than the radix.
Pandigital number 2026-10-20
A number whose representation contains every numerical digit from a specified alphabet. The convention must specify the base, whether zero is required, and whether repetitions are allowed. In many counting problems, “0-to-9 pandigital” means that all ten decimal numerical digits occur exactly once; other problems require only that each occur at least once.
Prime-proof number 2026-10-20
An integer for which replacing any one decimal numerical digit by a different digit never produces a prime number. The convention must specify whether changes creating a leading zero are permitted. An exact test enumerates the allowed substitutions and applies primality testing to each result.
Radix sort key encoding 2026-10-18
An encoding for radix sort must make the intended total order of sort keys agree with the lexicographic order of its fixed-width numerical digit tuples. The positional notation for bounded nonnegative integers has this property. At the most significant differing position , a one-unit numerical digit difference contributes , while all lower positions together contribute at mostThis geometric series shows why lower numerical digits cannot reverse that comparison. Leading zero padding works here because it preserves place values and the represented integer.
For signed integers in a known integer interval , encode and choose with . This order-preserving function is also injective: exactly when . For , the four-bit encodings of are after adding eight. Restore the original signed sort keys when displaying the complete sorting records; the encoding need not replace their data. Sorting the unsigned values of raw two's complement bit patterns would put nonnegative integers before negative ones, so their representation alone is not this ordered encoding.
For variable-length strings, first specify the alphabet order and whether a proper prefix precedes its extensions. As an original construction, use , let every string have length at most three, encode as one and as two, and append zeros to width three. Zero is reserved for an end marker strictly below every real symbol. The strings encode as in radix three, which preserves their lexicographic order. A differing real symbol decides the comparison; at a prefix boundary, the shorter string's zero comes before the extension's one or two. Left padding would instead encode as and as , reversing . Padding raw bytes with zero also fails if zero is an allowed data symbol: distinct strings can then receive the same encoding. A reserved end marker and an explicit symbol ordering are essential; byte order alone does not establish a desired human text order.
Stable ties preserve lower digits; suitable encodings preserve the intended order
. Original counterexample above: reversing a tens tie destroys the units order and a later stable hundreds pass cannot repair it. Below: signed integer offsets and a reserved end marker for bounded strings produce increasing fixed-width encodings. All entries are exact constructed examples. Details. Radix sort suffix invariant 2026-10-18
After passes, , the array is in nondecreasing order of , the integer represented by its lowest numerical digits. Equivalently it is ordered by the tuple under lexicographic order, with the most significant processed numerical digit first. Among equal suffixes it retains the original order of the complete sorting records.
The loop invariant has a simple mathematical induction proof. Before any pass, for every sort key, so the original array satisfies it. Suppose it holds after passes. The next stable digit sort puts smaller groups first and preserves the existing order within each tie. Sincethe new array is ordered by . Equal new suffixes have equal current numerical digits and equal old suffixes, so their original order is also preserved. Every pass is a permutation of complete sorting records, establishing sorting permutation preservation. At termination , the assumption gives : the invariant becomes whole-key sortedness, together with stable sorting.
Repunit 2026-10-20
A repdigit whose digits are all 1 in a specified positional notation of base . Its value is the geometric series . In base ten, appending one digit gives , so its remainder modulo can be computed by a recurrence relation without constructing the full integer.
Reversible number 2026-10-20
A positive integer whose sum with its digit reversal has only odd numerical digits, with leading zeros forbidden in both the original and reversed representations. For example, . Studying the arithmetic carries of mirrored digit pairs allows whole lengths to be counted without enumerating all integers of that length.
Stable digit sort 2026-10-18
A stable digit sort applies stable sorting to complete sorting records using one specified numerical digit of their encoded sort keys. Counting sort can supply it; stable record placement in counting sort moves records without discarding their associated data. Stability concerns equal current numerical digits, even when the full sort keys differ. This is the information-preservation step in least-significant-digit radix sort.[ref]
11.2 Counting Sort and Radix Sort. Open Data Structures: An Introduction by Pat Morin; §11.2.1, associated-data and stability paragraphs; §11.2.2, least-significant passes and correctness paragraph after Figure 11.8
An original two-record counterexample exposes the need for the tie rule. Start with at width three. A units pass gives . Both tens numerical digits are four. A deliberately unstable tens pass may reverse their tie and return : it is sorted by the tens numerical digit, yet its two-position suffixes are decreasing. The final stable hundreds pass sees two zeros and keeps this wrong order. Sorting permutation preservation still holds, but sortedness fails. Stability in the tens pass would have retained the units information.
With counting sort as the stable digit sort, each pass initializes counters, counts current numerical digits, constructs their prefix sums, and places complete sorting records. Thus each pass costs , and passes cost in Big O notation. Reuse the counters and two arrays of record references between passes: auxiliary space complexity is , rather than . Assume constant-cost numerical digit extraction, counter arithmetic, array indexing and record-reference movement; the bound counts these operations, not the cost of copying arbitrarily large payloads or performing arbitrary-precision integer arithmetic.
The benefit is avoiding a counter for every possible whole sort key: width has possibilities, while each pass needs only counters. A larger radix reduces the number of passes for a fixed key range but enlarges the counter array. The comparison sorting lower bound does not apply to these direct array indices; they reveal more than a two-way comparison. Nor does fixing make disappear: growing key width still increases work.

