Output for finding kth digit from right of a^b does not come as Expected?
<blockquote>
  <p>Given two numbers a and b, find kth digit from right of a^b? </p>
</blockquote>

<p>Link for the problem:</p>

<p><a href="http://www.practice.geeksforgeeks.org/problem-page.php?pid=302" rel="nofollow">http://www.practice.geeksforgeeks.org/problem-page.php?pid=302</a></p>

<p>MyApproach:</p>

<p>I took 4 numbers as Input.First was the number of test cases.Then,Input was numbers a b and k respectively(Seperated by space).I calculated a^b and then from right searched each number till the time kth digit is not equal to the count.If I get them equal I returned the remainder expected.</p>

<p>Below is the Code:</p>

<pre><code>public static void main (String[] args) 
{
       Scanner sc=new Scanner(System.in);
          int T=sc.nextInt();

          for(int i=1;i&lt;=T;i++)
          { 
              int count=1;
              int a=sc.nextInt();
              System.out.print(" ");
              int b=sc.nextInt();
               System.out.print(" ");
              int k=sc.nextInt();
              long result=(long) Math.pow(a,b);
              if(k!=count)
              {
                  while(k!=count)
                  {
                      count++;
                      int remainder=(int) (result%10);
                      result=result/10;

                  }
              }
              result=result%10;
              System.out.println(result);
          }
    }


GeeksId Output:                  

Wrong !! Here your code Failed 

Input: 

7 6 3 

And its Correct output is: 

6
</code></pre>

<p>Eclipse ID:</p>

<p>Input: </p>

<p>7 6 3 </p>

<p>Output</p>

<p>6</p>

<blockquote>
  <p>Wny I am getting Failed on geeksId?Is my solution do not produce correct output?</p>
</blockquote>