complete getLeftmostDigit function