C# Code: Got errors namespace _21._14SieveofEratosthenes { class Program { stati
ID: 3891218 • Letter: C
Question
C#
Code: Got errors
namespace _21._14SieveofEratosthenes
{
class Program
{
static ListSeiveWithoutMod(int candidate)
{
BitArray sieveContainer = new BitArray(candidate + 1, true);
int maker = 2;//start
int factor = 2;//start.
sieveContainer[0] = false;//0 is not prime
sieveContainer[1] = false;//1 is not prime
while ((maker * maker) <= sieveContainer.Length)
{
while ((factor += maker) <= candidate)
{
sieveContainer[factor] = false;
};
factor = ++maker;//reset
}
//return only the "true"indexes
return GetPrimes(sieveContainer);
}
}
}
Explanation / Answer
The code you provided contains a method named ListSeiveWithoutMod which does not contain return type. It must contain a return type like int or void., or something as per your function defintion.
As the ListSeiveWithoutMod method returns the value returned by GetPrimes method so these 2 methods will have same return type. In case of any other doubts just comment down.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.