Yes, @pavitra_ag Here we are calculating modular exponentiation. Name of method used is fast exponentiation. As the name suggest it is faster method to calculate power of a no. Sometimes both are used interchangeably to mean same.
Means calculate a to the power b and then take mod n. This method takes O(logn) time. And is quite fast to calculate a to the power b and then take mod n.
Yes, you can call them essentially the same, aside from minor difference @aryanc403 pointed out. People use them interchangeably
I am not good in maths… “So, we have cnt choices for D1,DN and 10N−2 choices for rest of the N−2 digits. Thus, the answer will be cnt∗10N−2%(109+7)”, how did 10N-2 come into picture?
This is due to no of digits which can be at D2 is 10,D3 is 10,D4 is 10 and so on. All these satisfy given requirement so we multiply by 10 for all these no.
e.g. - Let w=8. n=4
We have D4=9, D1=1.
possible combinations are -
9001, 9011, 9021… 9091,
9101, 9111, 9021… 9191,
9201, 9211, 9221… 9291,
9901, 9911, 9921… 9991.
As you can see all no except 1 and 4 can form a 2 digit no from 0 to 99.
Hence 100 possible no.
For w=7. n=4 you can try
9002, 8001. And write no in similar fashion. There will be 100 possible combinations for 2m3 digit and for 1 and for 2 possible, And we will get 200 poss answers.
Basic combinatorics. What are the possible values which all the N-2 digits can take (except first digit and last digit)? Anything from 0 to 9. Total choices per digit =10. Number of digits$= N-2$. Hence Ans= 10*10*10....N-2 times. Hence {10}^{N-2}