Advertisement
Guest User

Higher or Lower

a guest
Feb 10th, 2012
1,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.46 KB | None | 0 0
  1. numguess:-numGuess(100,1).
  2. numGuess(Top,Bottom):-write('Is your number less than '),Middle is truncate((Top + Bottom) / 2),write(Middle),write('? [y/n]'),read(y), numGuess(Middle - 1,Bottom).
  3. numGuess(Top,Bottom):-write('Is your number greater than '),Middle is truncate((Top + Bottom) / 2),write(Middle),write('? [y/n]'),read(y), numGuess(Top,Middle + 1).
  4. numGuess(Top,Bottom):-write('Your number is '),Middle is truncate((Top + Bottom) / 2),write(Middle),write('.').
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement