#include<stdio.h>
void main()
{
int a,n,j,Sn,k;
printf("input a:\n");
scanf("%d",&a);
while(a==0)
{
printf("This is error,input a:\n");
scanf("%d",&a);
}
printf("inpur n:\n");
scanf("%d",&n);
while(n<=0)
{
printf("This is error,input n:\n");
scanf("%d",&n);
}
Sn=0;k=1;
for(j=1;j<=n;j++)
{
k*=a;
Sn+=k;
}
printf("Sn=%d\n",Sn);
}