solution to Valid Number