I have an expression as:
$$\sum_{k=0}^{m}{(-1)^k}\binom{m}{k}{(2)^{n(m-k)}}$$
Constraints: $1\le n, m \le 10^{6}$
It is a programming question and I am required to find the answer $\pmod {10^{9} + 7}$. I can do it in O(m) time complexity using preprocessing. I didn't post this on stack overflow because it involves more math and little programming. I have to calculate the above expression for different pairs $(m, n)$ , so is there a way to find it faster or some closed form.
Binomial Theorem: $$(1-x)^{m}=\sum_{k=0}^{m} {m \choose k} (-x)^k~~~~~(1)$$ $$S=\sum_{k=0}^{m}{(-1)^k}\binom{m}{k}{(2)^{n(m-k)}}=2^{nm} \sum_{k=0}^{m} {m \choose k}(-2^{-n})^k=2^{nm}(1-\frac{1}{2^n})^m=(2^n-1)^m.$$