Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!

Higher or Lower

By: a guest on Feb 10th, 2012  |  syntax: Prolog  |  size: 0.46 KB  |  views: 756  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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('.').
clone this paste RAW Paste Data