Advertisement
Joao_Joao

Questão 265 Lista de Exercícios IFPB

May 21st, 2022
1,113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int fib(int n) {
  4.   if(n == 1) return 0;
  5.   if(n == 2) return 1;
  6.   return fib(n-1) + fib(n-2);
  7. }
  8.  
  9. void main() {
  10.   int n;
  11.   scanf("%d", &n);
  12.   printf("Enesimo termo da sequencia de Fibonacci: %d\n", fib(n));
  13. }
  14.  
Advertisement
RAW Paste Data Copied
Advertisement