**The Kaprekar Series!**

(http://kaprekar.sourceforge.net)

Discovered by an Indian Mathematician in the 1950s, this series bears his name. He found that, given any 4-digit number, with distinct digits; on applying the Kaprekar process it will distill down to a single number - 6174 - called the Kaprekar constant.

The process is very simple.

Take any 4-digit number, say 1234.

Now write its digits in ascending and descending orders - 1234 and 4321 and subtract the two numbers so formed -

4321

- 1234

---------

3087

Repeat the above process and you get these numbers after each step:

1234 -> 3087 -> 8352 -> 6174 -> 6174 -> 6174

hmm. You see the pattern?

Similarly, if you take up a 3-digit number (with distinct digits), you'll end up with 495 on applying the Kaprekar process.

For 2-digit number, it gets interesting. You don't end up with one specific number, but a sequence of numbers!

09 -> 81 -> 63 -> 27 -> 45 -> 09

For higher number of digits, you typically end up in one of many sequences!

For 5-digits - it will be one of three sequences

For 6-digits - its either 631764, or 549945 or a sequence

For 7-digits - you'll end up in a sequence of 8 numbers

and so on ...

I have put the java code I used to generate the series, for public download at

http://kaprekar.sourceforge.net