:- module( _, [perm/2], [assertions , regtypes , basicmodes , nativeprops] ).

perm([[num(int(A))]],[num(int(-1))]) :-
        A<0 .
perm([[num(int(A))]],[num(int(1))]) :-
        A>=0,
        A=<0 .
perm([[num(int(A))]],[num(int(B))]) :-
        A>=0,
        A>0,
        B is 1*A,
        C is A+ -1,
        C=<0 .
perm([[num(int(A))]],[B]) :-
        A>=0,
        A>0,
        C is 1*A,
        D is A+ -1,
        D>0,
        E is C*D,
        execute_notrace_1(D,E,_1,_2,_3,_4,_5,B,_6) .

execute_notrace_1(A,B,[],_1,_2,_3,_4,num(int(B)),[]) :-
        C is A+ -1,
        C=<0 .
execute_notrace_1(A,B,C,D,E,F,G,H,I) :-
        J is A+ -1,
        J>0,
        K is B*J,
        execute_notrace_1(J,K,C,D,E,F,G,H,I) .


