18 Star 133 Fork 63

编程语言算法集 / C-Sharp

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
FermatNumbersSequence.cs 752 Bytes
Copy Edit Raw Blame History
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;
}
}
}
}
C#
1
https://gitee.com/TheAlgorithms/C-Sharp.git
git@gitee.com:TheAlgorithms/C-Sharp.git
TheAlgorithms
C-Sharp
C-Sharp
master

Search