Code to handle exception for negative numbers in factorial program