18 Star 133 Fork 63

编程语言算法集 / C-Sharp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CakeNumbersSequence.cs 714 Bytes
一键复制 编辑 原始数据 按行查看 历史
using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Cake numbers: maximal number of pieces resulting from n planar cuts through a cube
/// (or cake): C(n+1,3) + n + 1.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000125.
/// </para>
/// </summary>
public class CakeNumbersSequence : ISequence
{
public IEnumerable<BigInteger> Sequence
{
get
{
var n = new BigInteger(0);
while (true)
{
var next = (BigInteger.Pow(n, 3) + 5 * n + 6) / 6;
n++;
yield return next;
}
}
}
}
C#
1
https://gitee.com/TheAlgorithms/C-Sharp.git
git@gitee.com:TheAlgorithms/C-Sharp.git
TheAlgorithms
C-Sharp
C-Sharp
master

搜索帮助