How a NTM guessing depends on the input?
Suppose that the input has length $n$, and suppose that the machine already knows $n$. In order to non-deterministically choose a number from 1 to $n$, it performs the following algorithm:


Choose $m = \lceil \log_2 n \rceil$ bits non-deterministically, and interpret them as a number $x$ from $0$ to $2^m-1$.
Increase $x$ by one.
Reject if $x &gt; n$.


The first step is implemented by a loop.