Compute remainders from right to left when divided by ' b '
int [ ] rl = new int [ len + 1 ] ; rl [ len - 1 ] = ( ( int ) str [ len - 1 ] - ( int ) '0' ) % b ; int power10 = 10 ; for ( int i = len - 2 ; i >= 0 ; i -- ) { rl [ i ] = ( rl [ i + 1 ] + ( ( int ) str [ i ] - ( int ) '0' ) * power10 ) % b ; power10 = ( power10 * 10 ) % b ; }