C# 递归算羊

public int ganyang(int cun)
{
  if (cun == 7)
  {
    return 2;
  }

  int sum = (ganyang(cun + 1) + 1) * 2;

  return sum;
}

Console.WriteLine(new Program().ganyang(0));

posted @ 2015-11-05 22:32  最讨厌起名字什么的了  阅读(190)  评论(0编辑  收藏  举报