fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a1, q, n, soma = 0;
  5. scanf("%d %d %d", &a1, &q, &n);
  6. for (int i = 0; i < n; i++) {
  7. printf("%d\n", a1);
  8. a1 *= q;
  9. soma += a1;
  10. }
  11. printf("%d\n", soma);
  12. }
  13.  
  14. //https://pt.stackoverflow.com/q/441956/101
Success #stdin #stdout 0s 4504KB
stdin
1
2
10
stdout
1
2
4
8
16
32
64
128
256
512
2046