Define a function kaprekar(n, b) that will computer Kaprekar's operation on an integer n expressed in base b. Now we can explore the properties of this function. We know that if base = 10, the integer's digits in base 10 aren't all the same, and the integer has four digits, the function has a fixed point at 6174. Under what other bases and digit-counts does the function have a fixed point? Is it possible for kaprekar(a, b) to return an integer c with fewer digits than a, assuming once again that the digits are non-uniform? Etc.
"Number of digits in n" is shorthand for "floor(log(b)n) + 1" and the digits themselves can be expressed in terms of modulus (while n > 0: digits.append(n % b); n = n / b). Speaking in terms of digits just makes it easier to talk about what are really rather odd mathematical operations. It's true that their primary use is in our number representation system, but that doesn't make them any less interesting from a pure-mathematical viewpoint.
"Number of digits in n" is shorthand for "floor(log(b)n) + 1" and the digits themselves can be expressed in terms of modulus (while n > 0: digits.append(n % b); n = n / b). Speaking in terms of digits just makes it easier to talk about what are really rather odd mathematical operations. It's true that their primary use is in our number representation system, but that doesn't make them any less interesting from a pure-mathematical viewpoint.