The requirement of regnum/1 was only to enumerate
the positive part of regular numbers, not to
check whether something is a regular number.
I guess Michael Ben Yosef, which doeesnt use
CLP(FD), does also not terminate for the
call pattern regnum(+Integer),
and only works sensible for regnum(-Integer).
Which is fine concerning this riddle. For
a call pattern regnum(+Integer),
you would proceeed completely different,
not enumerate all numbers before N, but
directly attack factoring of N:
regnum(N) :- integer(N), !,
regnum_fastpath(N).
regnum(N) :-
/* Michael Ben Yosef path */
regnum_fastpath(1) :- !.
regnum_fastpath(N) :- N mod 2 =:= 0, !,
M is N//2, regnum_fastpath(M).
regnum_fastpath(N) :- N mod 5 =:= 0, !,
M is N//5, regnum_fastpath(M).