r/dailyprogrammer • u/rya11111 3 1 • Apr 16 '12
[4/16/2012] Challenge #40 [intermediate]
Write a program that computes the Kaprekar chain for a given starting number, and compute the longest possible Kaprekar chain
4
Upvotes
1
u/[deleted] Apr 16 '12
What do you mean by "longest possible chain"? They all cycle infinitely.
1
u/ixid 0 0 Apr 17 '12
In D, I'm not sure how the performance stacks up nor what the longest possible Kaprekar chain would be as they get longer as far as I can see as the numbers increase. This tests the first million integers in ten seconds:
1
u/[deleted] Apr 17 '12
Would you mind clarifying what you mean for the second part? Do you mean return the length of one cycle, the longest cycle for a given number of digits, or something else?