% ?- who(26). 7 and 17
who(N) :- N1 is N-1, gen([1|L], N1), write([1|L]),nl, del([1|L]).

% generacya massiva [1, 2, ..., N]
gen([_], 0) :- !.
gen([A,B|L], N) :- B is A+1, N1 is N-1, gen([B|L], N1).

% udalenie kajdogo 3-ego
del([A,B])     :- write(A), write(' and '), write(B), nl, !.
del([A,B,_|L]) :- obed(L,A,B, R), del(R).

% ob'edinenie massiva s 2-mya vijivshimi
obed([X|L],A,B, [X|R]) :- obed(L,A,B, R).
obed([],A,B, [A,B]).
