namespace to catch the sheep in the hand
{
Class Program
{
public int Jisuan (Int. day)//Create a function, enter day to calculate the total number of sheep
{
int sum=0;
if (day==7)
{
sum = 2;
return sum;//Be sure to add a return deadline
}
sum = (Jisuan (day + 1) + 1) * 2;//To count the day's sheep, you need to count the day's sheep. Sheep sell half a day and add one extra .
return sum; //returns sum of type int
}
static void Main (string[] args)
{
while (true)
{
There are some other functions in the #region//that are not used in this function
//int sum=2;
//for (int i = 0; I <7; i++)
//{
//sum = (sum + 1) * 2;
//}
//console.writeline (sum);
#endregion
Console.WriteLine ("Please enter the day");
int m = Convert.ToInt32 (Console.ReadLine ());
int sum = new program (). Jisuan (m);//define a sum of type int to receive the function result of Jisuan function input M-day
Console.WriteLine ("s" + M + "days for" + Sum + "only.) ");
Console.ReadLine ();
}
}
}
}
Recursive function--catching sheep