It is related to problem :http://www.codechef.com/problems/MARCHA4
where we are supposed to find first and last k digits of n^n.
To find first k digits i have seen people using some log and floor functions…complete code is below:
long int firstKdigits(long long n,int k)
{
long double x, y;
x = n*log10(n);
y = floor(pow(10,x-floor(x) +k-1));
return ((int)y);
}
Can someone provide me proof of this…how it gives first k digits??