forked from TheAlgorithms/C-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFermatPrimesSequence.cs
36 lines (34 loc) · 945 Bytes
/
FermatPrimesSequence.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Fermat primes: primes of the form 2^(2^k) + 1, for some k >= 0.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Fermat_number.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A019434.
/// </para>
/// </summary>
public class FermatPrimesSequence : ISequence
{
/// <summary>
/// Gets sequence of Fermat primes.
/// </summary>
public IEnumerable<BigInteger> Sequence
{
get
{
var fermatNumbers = new FermatNumbersSequence().Sequence.Take(5);
foreach (var n in fermatNumbers)
{
yield return n;
}
}
}
}
}