What data type is the number stored in? String or int or long or ?
If not String, convert it to a String and then use one of the String class's methods to look at the digits one at a time in a loop...