Updated code to not include duplicate numbers in output