The original author is David Moser; I originally saw it in one of
Douglas Hofstadter's old Metamagical Themas columns in Scientific
American (it's in ch. 2 of my anthology of those columns; no date
is given for any of the columns but credits for the illustrations
in that column give a copyright date of January 1982).
rst