I am multiplying many large numbers and finally taking modulo of it. To optimise this I am using MOD at each step. But I also want the 1st digit of the final answer. Is there any way to know that even after using MOD?
Or is there any other efficient way to do huge multiplication many times, get the final answer and extract the 1st digit from it?
Order of elements is 10^9 and number of multiplications is about 10^5
take 10 based logarithms, sum them up and take the fractional part of the sum.
think about scientific notation of large numbers.
1st digit before taking modulo(10**9 + 7)