While N > 0 compute the Nth digit by dividing p and q and store the result into variable res and go to next digit
while ( N > 0 ) { N -- ; p *= 10 ; res = parseInt ( p / q ) ; p %= q ; } return res ; }