- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathBinaryPrimeConstantSequence.cs
41 lines (37 loc) · 984 Bytes
/
BinaryPrimeConstantSequence.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
38
39
40
41
usingSystem.Collections.Generic;
usingSystem.Numerics;
namespaceAlgorithms.Sequences;
/// <summary>
/// <para>
/// Sequence of binary prime constant
/// (Characteristic function of primes: 1 if n is prime, else 0).
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Prime_constant.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A010051.
/// </para>
/// </summary>
publicclassBinaryPrimeConstantSequence:ISequence
{
/// <summary>
/// Gets sequence of binary prime constant.
/// </summary>
publicIEnumerable<BigInteger>Sequence
{
get
{
ISequenceprimes=newPrimesSequence();
varn=newBigInteger(0);
foreach(varpinprimes.Sequence)
{
for(n++;n<p;n++)
{
yieldreturn0;
}
yieldreturn1;
}
}
}
}