fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int a,n,i,s=1,sum=0;
  6. scanf("%d",&a);
  7. scanf("%d",&n);
  8. for(i=1;i<=n;i++){
  9. s=s*a;
  10. sum=sum+s;}
  11. printf("%d",sum);
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0.01s 5280KB
stdin
5
3
stdout
155