Kaprekar numbers: Difference between revisions
Cleaned up the description some, but much more is needed.
(Added third version, as suggested.) |
(Cleaned up the description some, but much more is needed.) |
||
Line 1:
{{task}}
In this task, generate andshow all Kaprekar numbers less than 10,000. For extra credit, count (and report the count of) how many Kaprekar numbers are less than 1,000,000.
A positive integer is a [[wp:Kaprekar number|Kaprekar number]] if it is 1, or if the string representation of its square can be split once into parts consisting of positive integers that when summed add up to the original number.▼
▲A positive integer is a [[wp:Kaprekar number|Kaprekar number]] if it is 1, or if the string representation of its square
For example 2223 is a Kaprekar number as 2223*2223 == 4941729 and 494 + 1729 == 2223▼
;Example Kaprecar numbers:
The series of Kaprekar numbers begins: [[oeis:A006886|1, 9, 45, 55, ...]].▼
▲
▲* The series of Kaprekar numbers begins: [[oeis:A006886|1, 9, 45, 55, ...]].
;Example process:
* The first split is [1, 0000], which is not OK because "a split of all zeroes is not counted; zero is not considered positive".
* Slight optimization opportunity: When splitting from left to right, once the right part consists of all zeroes, no further testing is needed; all further splits would also be invalid.
;Reference:
Line 14 ⟶ 18:
;Note
In comparing splits of the square, a split of all zeroes is not counted
▲Example: 10000 (100<sup>2</sup>) splitting from left to right:
=={{header|C}}==
|