Solution to Valid Number