home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / ANSWERS.ARC / ANS_170D.PRO < prev    next >
Encoding:
Prolog Source  |  1988-06-21  |  568 b   |  31 lines

  1. /*
  2.    Turbo Prolog 2.0, Answer to fourth Exercise on page 170.
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5. */
  6.  
  7. Predicates
  8.   mult_x_itself ( real )
  9.  
  10. Clauses
  11.  
  12.   mult_x_itself(X) :-
  13.       X <= 1 ,
  14.       !, write("no\n").
  15.  
  16.   mult_x_itself(81) :- 
  17.       write("yes\n"), !.
  18.  
  19.   mult_x_itself(Num) :-
  20.       Num > 81 ,
  21.       !, write("no\n").
  22.  
  23.   mult_x_itself(Num) :-
  24.       Num1 = Num * Num ,
  25.       mult_x_itself(Num1).
  26. Goal
  27.   makewindow(1,2,3,"",0,0,25,80) ,
  28.   write("\nEnter a number: ") ,
  29.   readreal(Number) ,
  30.   nl,
  31.   mult_x_itself(Number), nl.