The user is entering a number. That some values are invalid for technical reasons does not change the nature of the user interaction. I would go with an option that is the most natural to enter a number
Perhaps keep a regular number field, but when the user finishes their input, nudge the number to the closest valid option with a minor message to go with it?...
I think a horizontal slider with:
Graduations (tick marks) showing the possible values
A handle with a triangle end pointing to those tick marks
Snapping to the closest possible value when you drop the handle
A feedback of the actual value
Of course, the ability to manipulate with the keyboard
Optionally, the ability to use arrows or +/- to move to the next/...
Elementary factor seems to be fixing the error.
You need some intelligent code that will loop after the collection from * and if it encounters a hole, enter a value less than (index - 1) and greater than (index + 1).
Dropdown with 50 options is too mundane(but it's possible to implement search inside)
DatePicker - sounds reasonably, 2 interactions ...
The user should not be bothered with your historical reasons for limitations.
Prepare a mapping between valid values and consecutive numbers, e.g.:
Id: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Valid value: 1, 2, 3, 4, *, 6, *, 8, *, 12, *, 16, 17, 18
and present the Id's to the user only ("pick a number between 1 and 50"). Behind the screens ...
If you can combine a normal number input with a drop down menu that greys out invalid number, and centers on the number entered, with up and down arrows that go to the next valid number, that strikes me as the most intuitive.