Kaprekar Number - ISC Computer Science 2010 Practical
A positive whole number 'n' that has 'd' number of digits is squared and split into two pieces, a right-hand piece that has 'd' digits and a left-hand piece that has remaining 'd' or 'd - 1' digits. If the sum of the two pieces is equal to the number, then 'n' is a Kaprekar number . The first few Kaprekar numbers are: 1, 9, 45, 297, ... Example 1 : 9 9 2 = 81 Right-hand piece of 81 = 1 Left-hand piece of 81 = 8 Sum = 1 + 8 = 9 Example 2 : 45 45 2 = 2025 Right-hand piece of 2025 = 25 Left-hand piece of 2025 = 20 Sum = 25 + 20 = 45 Example 3 : 297 297 2 = 88209 Right-hand piece of 88209 = 209 Left-hand piece of 88209 = 88 Sum = 209 + 88 = 297 Given the two positive integers p and q, where p < q, write a program to determine how many Kaprekar numbers are there in the range between p and q (both inclusive) and output them. The input contains two positive integers p and q. Assume p < 5000 and q < 5000. You are to output the number...