factr(0,1). factr(N,F):- N_1 is N - 1, factr(N_1,F_1), F is N * F_1. facti(N,F):-facti(0,1,N,F). facti(N,F,N,F). facti(I,Fi,N,F):- J is I+1, Fj is J*Fi, facti(J,Fj,N,F). sum_to(1,1). sum_to(N,S):-N1 is N-1, sum_to(N1,S1), S is S1+N. sum_toc(N,1):-N=<1,!. sum_toc(N,S):-N1 is N-1, sum_toc(N1,S1), S is S1+N. /* sum_to(2,3):- 1 is 2-1, sum_to(1,1), 3 is 1+2. sum_to(1,1). S1<-1 sum_to(1,S1):-0 is 1-1, sum_to(0,S1p), S1 is S1p+1. */ weird(1). parent(john,mary). parent(mary,mary). sibling(X,Y):-not(X=Y),parent(X,P),parent(Y,P). siblingx(X,Y):-notx(X=Y),parent(X,P),parent(Y,P). notx(P):-call(P),!,fail. notx(P). /* X = if A then B else C X:-A,!,B. X:-C. */