A balanced number is a positive integer whose first decimal digits have the same digit sum as its last decimal digits, where is the number of numerical digits. For odd , the middle numerical digit appears on both sides and cancels, so only the equally long outer halves need to be compared.
For example, is balanced because . It is not a palindromic number: equality of two digit sums does not require reversed digits. At odd length, is balanced because the outer pairs and both sum to three; its middle digit is irrelevant to the equality.
Digit dynamic programming can tabulate counts and value sums of fixed-length halves indexed by digit sum, then match equal indices. The first half must begin with a nonzero numerical digit, while the last half may contain initial zeros, as in . Preserving the half length is essential when assembling the positional value.
Articles by others on the same topic
There are currently no matching articles.