Tuesday, 30 September 2014

Project Euler 63: How many n-digit positive integers exist which are also an nth power

main()
 {
int i,j;//i is the base and j is power
 int count=0;//total number of such case
for(i=0;i<=10;i++)
{
for(j=0;j<=30;j++)
 {
 int x=(j*log10(i))+1;//length of i power j
 if(j==x) { {count++;}
}
 }
}
printf("%d",count);
 }

No comments:

Post a Comment