function fn(b, d) { function e() { var a = b + Math.random() * (d + 1 - b) | 0, c = prompt("Ваше число " + a + "?", "smaller/bigger/yes"); "yes" == c ? alert(a + "!!!") : ("bigger" == c && (b = a), "smaller" == c && (d = a), e()) } e() }; fn(1,100)