Print a string of fibonacci recursively in C#

前端 未结 11 723
你的背包
你的背包 2020-12-29 16:05

Can that be done with no while loops?

static void Main(string[] args)
{
    Console.WriteLine(\"Please enter a number\");
    int number = Convert.ToInt32(C         


        
11条回答
  •  长情又很酷
    2020-12-29 16:42

    public static int Fibonatchi(int position) {
    
        if(position == 0) {
            return 1;
        }
        if(position == 1) {
            return 1;
        } else {
            return Fibonatchi(position - 2) + Fibonatchi(position - 1);
        }
    }
    

提交回复
热议问题