Skip to content

Commit 0c516ee

Browse files
authored
Add all threes sequence (TheAlgorithms#352)
1 parent b24963c commit 0c516ee

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Algorithms.Sequences;
2+
using FluentAssertions;
3+
using NUnit.Framework;
4+
using System;
5+
using System.Linq;
6+
using System.Numerics;
7+
8+
namespace Algorithms.Tests.Sequences;
9+
public class AllThreesSequenceTests
10+
{
11+
[Test]
12+
public void First10ElementsCorrect()
13+
{
14+
var sequence = new AllThreesSequence().Sequence.Take(10);
15+
sequence.SequenceEqual(new BigInteger[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 })
16+
.Should().BeTrue();
17+
}
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Collections.Generic;
2+
using System.Numerics;
3+
4+
namespace Algorithms.Sequences;
5+
6+
/// <summary>
7+
/// <para>
8+
/// The all threes sequence.
9+
/// </para>
10+
/// <para>
11+
/// OEIS: https://oeis.org/A010701.
12+
/// </para>
13+
/// </summary>
14+
public class AllThreesSequence : ISequence
15+
{
16+
public IEnumerable<BigInteger> Sequence
17+
{
18+
get
19+
{
20+
while (true)
21+
{
22+
yield return 3;
23+
}
24+
}
25+
}
26+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ find more than one implementation for the same objective but using different alg
152152
* [A007318 Binomial](./Algorithms/Sequences/BinomialSequence.cs)
153153
* [A007395 All Twos](./Algorithms/Sequences/AllTwosSequence.cs)
154154
* [A010051 Binary Prime Constant](./Algorithms/Sequences/BinaryPrimeConstantSequence.cs)
155+
* [A010701 All Threes](./Algorithms/Sequences/BinaryPrimeConstantSequence.cs)
155156
* [A011557 Powers of 10](./Algorithms/Sequences/PowersOf10Sequence.cs)
156157
* [A057588 Kummer Numbers](./Algorithms/Sequences/KummerNumbersSequence.cs)
157158
* [A019434 Fermat Primes](./Algorithms/Sequences/FermatPrimesSequence.cs)

0 commit comments

Comments
 (0)