Dan,

No my formula can't handle 1,4,6.
I'm not able for a better one, but I'm sure there are others who are able to help you.