#include<stdio.h>
int main(void)
{
int num,n;
long pow(int num,int n);
printf("Now enter a number and N\n");
scanf("%d %d",&num,&n);
printf("a+aa+aaa+...=%ld\n",pow(num,n));
return 0;
}
long pow(int num,int n)
{
int i;
long sum=0,temp;
for(temp=num,i=1;i<=n;i++)
{
sum=sum+temp;
temp*=temp;
}
return sum;
}
嘿嘿,自写的pow()函数。。主要还是 a*=a这个东西
int main(void)
{
int num,n;
long pow(int num,int n);
printf("Now enter a number and N\n");
scanf("%d %d",&num,&n);
printf("a+aa+aaa+...=%ld\n",pow(num,n));
return 0;
}
long pow(int num,int n)
{
int i;
long sum=0,temp;
for(temp=num,i=1;i<=n;i++)
{
sum=sum+temp;
temp*=temp;
}
return sum;
}
嘿嘿,自写的pow()函数。。主要还是 a*=a这个东西
It's not a joke