A library that generates the Collatz Conjecture sequence
$ dotnet add package CollatzThis is a library that generates a sequence of integer values, based on the Collatz Conjecture. I'm primarly creating this package because I use this algorithm to demonstrate a number of development concepts in presentations, so having it as a NuGet package will make it easier to reuse it.
Simply reference the Collatz NuGet package - that's it.
This package targets .NET 9.
You can either get the entire sequence at once:
var sequence = CollatzSequenceGenerator.Generate(5);
// sequence will be [ 5, 8, 4, 2, 1 ]
Or get it as an enumerable:
foreach(var value in CollatzSequenceGenerator.GenerateStream(5))
{
Console.WriteLine(value);
}
/*
The following sequence will print to the console:
5
8
4
2
1
*/
If you run into any issues, please add them here.