forked from TheAlgorithms/C-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KummerNumbersSequence.cs
37 lines (35 loc) · 1020 Bytes
/
KummerNumbersSequence.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
37
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Kummer numbers (also called Euclid numbers of the second kind):
/// -1 + product of first n consecutive primes.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Euclid_number.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A057588.
/// </para>
/// </summary>
public class KummerNumbersSequence : ISequence
{
/// <summary>
/// Gets sequence of Kummer numbers.
/// </summary>
public IEnumerable<BigInteger> Sequence
{
get
{
var primorialNumbers = new PrimorialNumbersSequence().Sequence.Skip(1);
foreach (var n in primorialNumbers)
{
yield return n - 1;
}
}
}
}
}