I have tried various inputs and got the corresponding results. Not satisfying requirements 2, 3 and 5 each time. The while loop is used to find the number of digits. n/(int)Math.pow(10,j) extracts each digit. Hints on other ways would be helpful.