Solução: Problema da seqüência de Fibonacci (Fábio Novais)
From AdonaiMedrado.Pro.Br
Revision as of 23:48, 7 April 2009 by 200.17.147.2 (Talk)
using System;
public class SequenciaFibonacci { public static int GerarSequencia(int n) { if(n == 0 || n == 1) return n; else return GerarSequencia(n - 1) + GerarSequencia(n - 2); } }
public class Principal { public static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine());
if((n <= 40) && (n >= 0)) { for(int i = 0; i < n; i++) Console.WriteLine(SequenciaFibonacci.GerarSequencia(i)); } else Console.WriteLine("Numero invalido!"); } }