using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
///
///
/// Sequence of binary prime constant
/// (Characteristic function of primes: 1 if n is prime, else 0).
///
///
/// Wikipedia: https://wikipedia.org/wiki/Prime_constant.
///
///
/// OEIS: https://oeis.org/A010051.
///
///
public class BinaryPrimeConstantSequence : ISequence
{
///
/// Gets sequence of binary prime constant.
///
public IEnumerable Sequence
{
get
{
ISequence primes = new PrimesSequence();
var n = new BigInteger(0);
foreach (var p in primes.Sequence)
{
for (n++; n < p; n++)
{
yield return 0;
}
yield return 1;
}
}
}
}