1 Star 0 Fork 0

jobily/TheAlgorithms-C-Sharp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
FermatNumbersSequence.cs 752 Bytes
一键复制 编辑 原始数据 按行查看 历史
Gerson Jr 提交于 2024-01-03 22:51 . Switch to file-scoped namespaces (#432)
using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Sequence of Fermat numbers: a(n) = 2^(2^n) + 1.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Fermat_number.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000215.
/// </para>
/// </summary>
public class FermatNumbersSequence : ISequence
{
/// <summary>
/// Gets sequence of Fermat numbers.
/// </summary>
public IEnumerable<BigInteger> Sequence
{
get
{
var n = new BigInteger(2);
while (true)
{
yield return n + 1;
n *= n;
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hubo/the-algorithms-c-sharp.git
git@gitee.com:hubo/the-algorithms-c-sharp.git
hubo
the-algorithms-c-sharp
TheAlgorithms-C-Sharp
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385