ramontricolor12

LISTA 03 - Exercício 23

Jun 28th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 03 - Exercicio 23.c
  3.    Objetivo: Exiba o n-ézimo numero da sequencia fibonacci.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. int main()
  9. {
  10.     int  i, anterior = 1, atual = 1, aux = 0, posicao;
  11.  
  12.     printf("\nInforme uma posicao: ");
  13.     scanf("%d", &posicao);
  14.  
  15.     if(posicao > 2)
  16.         for(i = 3; i <= posicao; i++)
  17.         {
  18.             aux = atual;
  19.             atual += anterior;
  20.             anterior = aux;
  21.         }
  22.     printf("\n%d* POSICAO DA SEQUENCIA : %d\n", posicao, atual);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment