forked from TheAlgorithms/C-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCubesSequence.cs
36 lines (34 loc) · 841 Bytes
/
CubesSequence.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.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of cube numbers.
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Cube_(algebra).
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000578.
/// </para>
/// </summary>
public class CubesSequence : ISequence
{
/// <summary>
/// Gets sequence of cube numbers.
/// </summary>
public IEnumerable<BigInteger> Sequence
{
get
{
var n = BigInteger.Zero;
while (true)
{
yield return n * n * n;
n++;
}
}
}
}
}