11.07.2015 Views

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

41) A série de Fibonacci é formada pela seqüência:1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...Escreva um algoritmo em PORTUGOL que gere a série de FIBONACCI até o N-ésimo termo.algoritmo L3P041;varinteiro: N, C, ATUAL, ANT1, ANT2;inícioleia(N);ANT2 ← 1;ANT1 ← 1;imprima(ANT2);imprima(ANT1);para C de 3 até N façaATUAL ← ANT1 + ANT2;imprima(ATUAL);ANT2 ← ANT1;ANT1 ← ATUAL;fim-parafimprogram l3p041;varN, C, ATUAL, ANT1, ANT2: integer;beginwrite('Digite o numero de termos: ');read(N);ANT2 := 1;ANT1 := 1;writeLn(ANT2);writeLn(ANT1);for C := 3 to N dobeginATUAL := ANT1 + ANT2;writeLn(ATUAL);ANT2 := ANT1;ANT1 := ATUAL;end;end.% N, C, ATUAL, ANT1, ANT2: integer;N = input('Digite o numero de termos: ');ANT2 = 1;ANT1 = 1;disp(ANT2);disp(ANT1);for C = 3 : NATUAL = ANT1 + ANT2;disp(ATUAL);ANT2 = ANT1;ANT1 = ATUAL;end<strong>UFMG</strong> – ICEx – <strong>DCC</strong> – Programação de Computadores – 2º. Sem 2005 – David Menoti 41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!