title: Find the kth digit after the decimal point of a fraction a/b with a,b,k being very large integers (less than 10e18)
body: <p>I was tasked to find a digit of kth position after the decimal point of a fraction(a/b).
  Yesterday I found out this algorithm.<br>
  To get any digit after the decimal point, I generate a variable called rem and make a loop</p>
  
  <pre><code>for (int i = 1; i &lt;= k+1; i++)    
        {
           rem = a%b;
           a = rem*10;
        }
        cout &lt;&lt; a/b;    
  </code></pre>
  
  <p>the loop will return a value being the kth digit after the decimal point.<br>
  However the task require me to calculate with a,b,k being very large number ( less or equal to 10e18), so it's sure that the code will exceed the time limit. </p>
  
  <ul>
  <li>Find the number of the digits before the repetend. It's the greater of the numbers of 2 and 5 factors in the denominator.</li>
  <li>If the k doesn't exceed the number of digits, run the for loop.</li>
  <li>Else, we will still run the for loop to k+1. Store the value of the remainder of the division in a variable x.</li>
  <li>Run a while loop with the same content above until the remainder again have the value of x. Since then, store every quotient of the division into an array name qut.</li>
  <li>After the while loop terminates, the array will have stored every digit inside the repetend. According to the number of the digits inside the array, we can calculate the kth digit.<br>
  However, this algorithm still prove to be time consuming because in the case of a and b are two consecutive integer, the repetend become very large.
  Can you help me with any idea?</li>
  </ul>