This problem should be easily solved by binary search:

```
int guessNumber(int n) {
int low = 1;
while (low <= n) {
int mid = low + (n - low) / 2;
int guessRes = guess(mid);
if (guessRes == 0) {
return mid;
}
else if (guessRes == 1) {
low = mid + 1;
}
else {
n = mid - 1;
}
}
// number should be > n
return -1;
}
```

However, if I changed int mid=low+(n-low)/2; to int mid=low+(n-low)>>1; system returns error complaining indefinite loop.