% square(2,4).
% square(9,81).

% factorial
% show factorial(50,N).
% discuss run time
% reverse last two lines

factorial(0,1). 
factorial(N,F) :-  
   N>0, 
   N1 is N-1, 
   factorial(N1,F1),
   F is N * F1.







% Show off member

% show off change([Q,D,N,P]).
% show off change([3,D,N,P]).
% show off change([3,2,N,P]).
% show off change([Q,D,N,90]).
change([Q,D,N,P]) :- 
    member(Q,[0,1,2,3,4]),                  /* quarters     */ 
    member(D,[0,1,2,3,4,5,6,7,8,9,10]) ,    /* dimes        */ 
    member(N,[0,1,2,3,4,5,6,7,8,9,10,       /* nickels      */ 
               11,12,13,14,15,16,17,18,19,20]),  
    S is 25*Q +10*D + 5*N, 
    S =< 100, 
    P is 100-S. 

% Show off change([Q,D,N,P], 7).
% Note polymorphism

change([Q,D,N,P], Target) :- 
    member(Q,[0,1,2,3,4]),                  /* quarters     */ 
    member(D,[0,1,2,3,4,5,6,7,8,9,10]) ,    /* dimes        */ 
    member(N,[0,1,2,3,4,5,6,7,8,9,10,       /* nickels      */ 
               11,12,13,14,15,16,17,18,19,20]),  
    S is 25*Q +10*D + 5*N, 
    S =< 100, 
    P is Target-S. 


move(1,X,Y,_) :-  
    write('Move top disk from '), 
    write(X), 
    write(' to '), 
    write(Y), 
    nl. 
move(N,X,Y,Z) :- 
    N>1, 
    M is N-1, 
    move(M,X,Z,Y), 
    move(1,X,Y,_), 
    move(M,Z,Y,X).  
move(N) :- move(N, left, right,center).



% Show off http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_6.html
