Why six appears twice
transcript
A list of numbers. Only factors two, three and five. One, two, three, four, five, six. Then the list shows six twice. What went wrong?
Every number is an earlier one, times two, three or five. So there are three sorted lists. Each has one pointer into the answer. The next number is the smallest candidate.
Six is two times three, and three times two. Both candidates equal six. Move both pointers. Six is added once. Move one, and six comes out twice.
Take the smallest candidate. Move every pointer whose candidate matches. Equal candidates are one number. Then the list has no repeats.
The list is one, two, three, four, five, six, eight, nine. Seven is missing, because seven is a prime of its own. Six appears once. That is the test. Always test your list on six.
Equal candidates mean equal pointers move. Check it with six. Full breakdown in the lecture.