SHARE
TWEET

Untitled

a guest Jul 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  int main(void){
  5.  
  6.  int t1, r, n, tf, t,  somatoria, i, i2;
  7.  char p;
  8.  
  9.  printf("t1 = ");
  10.  scanf("%d", &t1);
  11.  printf("\nr = ");
  12.  scanf("%d", &r);
  13.  printf("\nn = ");
  14.  scanf("%d", &n);
  15.  printf("a ou g? ");
  16.  scanf("%*c%c", &p);
  17.  
  18.  if(p == 'a'){
  19.  
  20.     for(i = 1; i <= n; i+r){
  21.         i2 = 1;
  22.         printf("termo n %d = %d", i2, i);
  23.         i2++;
  24.     }
  25.     tf = (t1+(n-1))*r;
  26.     somatoria = ((t1+tf)*n)/2;
  27.     printf("somatoria = %d", somatoria);
  28.  
  29.  }else if(p == 'g'){
  30.     for(i = 0; i < n; i++){
  31.         t = t1*(pow(r, i));
  32.         printf("termo n %d = %d", i, t);
  33.     }
  34.     tf = t1*(pow(r, n));
  35.     somatoria = (t1*(r*pow(r, n))-1)/(r-1);
  36.  
  37.     printf("somatoria = %d", somatoria);
  38.  
  39.  }
  40.  
  41.  return 0;
  42.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top