main()
{
int num;
int j;//to save the value of i
int i;
int reserve;//for reserving the value of number.
static int sum[10];//for storing the value of result and static for making all array value initially zero.
static int a[10];//for storing value of individual power
int n=10;
int check;//for checking wether an element of array is getting carry or not.
for(num=1;num<=1000;num++)//Loop for taking all the numbers whose power is taken.
{
a[n-1]=num;
for(reserve=1;reserve<num;reserve++)//Loop for value of individual Power.
{
for(i=0;i<n;i++)//Loop for multiplying each array element with the number to get power;
{
a[i]*=num;
}
for(i=0;i<n;i++){//Loop for making all element of array single digit
if(a[i]>9)
{
check=a[i];
a[i]=(check%10);
check/=10;
j=i-1;
while(check!=0)
{
if(j<0){break;}
a[j]+=(check%10);
check/=10;
j--;
}
}
}
}
for(i=0;i<n;i++)//Summing the value of individual self power in sum array
{
sum[i]+=a[i];
a[i]=0;//To reinitialize all value of array to zero for next self power
//Now making all the value of array sum as single digit
if(sum[i]>9)
{
check=sum[i];
sum[i]=check%10;
check/=10;
j=i-1;
while(check!=0)
{if(j<0){break;}
sum[j]+=(check%10);
check/=10;
j--;
}
}
}
}
for(i=0;i<=9;i++)//for printing last 10 digits
{
printf("%d",sum[i]);
}
}
{
int num;
int j;//to save the value of i
int i;
int reserve;//for reserving the value of number.
static int sum[10];//for storing the value of result and static for making all array value initially zero.
static int a[10];//for storing value of individual power
int n=10;
int check;//for checking wether an element of array is getting carry or not.
for(num=1;num<=1000;num++)//Loop for taking all the numbers whose power is taken.
{
a[n-1]=num;
for(reserve=1;reserve<num;reserve++)//Loop for value of individual Power.
{
for(i=0;i<n;i++)//Loop for multiplying each array element with the number to get power;
{
a[i]*=num;
}
for(i=0;i<n;i++){//Loop for making all element of array single digit
if(a[i]>9)
{
check=a[i];
a[i]=(check%10);
check/=10;
j=i-1;
while(check!=0)
{
if(j<0){break;}
a[j]+=(check%10);
check/=10;
j--;
}
}
}
}
for(i=0;i<n;i++)//Summing the value of individual self power in sum array
{
sum[i]+=a[i];
a[i]=0;//To reinitialize all value of array to zero for next self power
//Now making all the value of array sum as single digit
if(sum[i]>9)
{
check=sum[i];
sum[i]=check%10;
check/=10;
j=i-1;
while(check!=0)
{if(j<0){break;}
sum[j]+=(check%10);
check/=10;
j--;
}
}
}
}
for(i=0;i<=9;i++)//for printing last 10 digits
{
printf("%d",sum[i]);
}
}
No comments:
Post a Comment