Advertisement
Joao_Joao

Questão 255 Lista de Exercícios IFPB

May 1st, 2022 (edited)
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int termo_inicial, razao;
  4.  
  5. int pa(int n) {
  6.   if(n <= 1) return termo_inicial;
  7.   return razao + pa(n - 1);
  8. }
  9.  
  10. int main() {
  11.   int N;
  12.   printf("Digite o valor do termo inicial: ");
  13.   scanf("%d", &termo_inicial);
  14.   printf("Digite o valor da razao: ");
  15.   scanf("%d", &razao);
  16.   printf("Digite o valor de N: ");
  17.   scanf("%d", &N);
  18.  
  19.   printf("O n-esimo termo da PA eh: %d\n", pa(N));
  20.  
  21.   return 0;
  22. }
  23.  
Advertisement
RAW Paste Data Copied
Advertisement