Refactored to have input number and output results.