Rabbit Born rabbit function recursion

Source: Internet
Author: User

Namespace Bunny rabbit function recursion
{
Class Program
{
static void Main (string[] args)
{
Console.WriteLine ("Please enter the number of months you want to know about rabbits:");
int m = Convert.ToInt32 (Console.ReadLine ());
int sum = new program (). Tuzi (m);//define a sum of type int to receive the result of the call's Tuzi function input m
Console.WriteLine ("+m+" month the number of rabbits is "+sum+" only. ");
Console.ReadLine ();
}
public int Tuzi (int yue)
{
int sum = 0;
if (yue==0)//No. 0 Month when the total number of rabbits is 1 pairs
{
sum = 1;
return sum;//return must be in all probability. Returns the value of a sum of type int
}
sum = Tuzi (yue-1) * *;the number of rabbits this month equals the number of rabbits last month
return sum;
}
}
}

Rabbit Born rabbit function recursion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.