int2list(0, []).
int2list(N, [1|L]) :- N > 0, M is N-1, int2list(M, L).

list2int([], 0).
list2int([1|L], N) :- list2int(L, M), N is M+1.
