Search algorithm to find integer input that produces the first 'True' (bool: 1) occurence of a computationally expensive boolean function
Use binary search.

You know that the correct value is somewhere in the range $[n_\min,n_\max]$, so pick $t = \lfloor (n_\min+n_\max)/2 \rfloor$ (the point halfway in the middle), and evaluate $f(t)$.  This will either tell you that $n^*$ is in $[n_\min,t]$ or that $n^*$ is in $[t+1,n_\max]$.  Now you can repeat on the smaller interval.  Each time, the width of the interval decreases by a factor of two, so after $\lg (n_\max-n_\min)$ iterations, you will find the correct value of $n^*$.  This is much faster than trying all $n_\max-n_\min$ possible values of $n^*$.