refact(CSharp): rename from PrimeGenerator to GeneratePrimeNumbers (#507)
parent
43e122cb9b
commit
27aa8dc3f7
|
@ -7,7 +7,7 @@ namespace Algorithms.NumberTheory
|
||||||
public class SieveOfEratosthenes
|
public class SieveOfEratosthenes
|
||||||
{
|
{
|
||||||
// returns all the prime numbers from 1 to max
|
// returns all the prime numbers from 1 to max
|
||||||
public static List<int> PrimeGenerator(int max)
|
public static List<int> GeneratePrimeNumbers(int max)
|
||||||
{
|
{
|
||||||
List<bool> isPrime = Enumerable.Repeat(true, max + 1).ToList();
|
List<bool> isPrime = Enumerable.Repeat(true, max + 1).ToList();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace Algorithms.NumberTheory
|
||||||
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
List<int> primeNumbers = PrimeGenerator(100);
|
List<int> primeNumbers = GeneratePrimeNumbers(100);
|
||||||
Console.WriteLine(string.Join(", ", primeNumbers));
|
Console.WriteLine(string.Join(", ", primeNumbers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Algorithms.Tests.NumberTheory
|
||||||
[TestCase(100, "2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97")]
|
[TestCase(100, "2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97")]
|
||||||
public void SieveOfEratosthenes_ShouldReturnExpected(int max, string expected)
|
public void SieveOfEratosthenes_ShouldReturnExpected(int max, string expected)
|
||||||
{
|
{
|
||||||
List<int> primeNumbers = Algorithms.NumberTheory.SieveOfEratosthenes.PrimeGenerator(max);
|
List<int> primeNumbers = Algorithms.NumberTheory.SieveOfEratosthenes.GeneratePrimeNumbers(max);
|
||||||
Assert.AreEqual(expected, string.Join(", ", primeNumbers));
|
Assert.AreEqual(expected, string.Join(", ", primeNumbers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue