SHARE
TWEET

Higher or Lower

a guest Feb 10th, 2012 775 Never
  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('.').
RAW Paste Data
Top