first k digits

(unsigned long) floor (pow(10.0,modf(n*log((double)n),&dummy)+k-1)
log is on d base 10

last k digits

int func(int n,int k){
int m=1;
for(;k>0;k--) m*=10;
r=1; t=n%m;
while(n){
   if(n%2)
       r=r * t%m;
   t=t * t%m;
   n>>=1;
}
return r;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to