If we use EXGCD, it takes $O(\log_22^p)=O(p)$ time, which is not efficient enough.
Some small values are 3, 13, 55, 931, 3781, 61681, 248347, 4011943, 259179061......
It seems that $I(p)$ is slightly smaller than $2^{p-1}$, but I didn't find more explicit patterns, nor did I find the sequence on OEIS.
So is there a closed form of $I(p)$, or at least can we calculate that more efficiently?
Any idea would be appreciated!
