Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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);
}
}
}

array of LinkedListcints buckets. 21.14 (Sieve of Eratosthenes with BitArray) Investigate class BitArray in namespace System.Col- lections.Specialized, then use it to reimplement Exercise 8.27's Sieve of Eratosthenes algorithm. Measure the performance of this version vs. the one in Exercise 8.27. Which is faster? Functional-Programming Exercises

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.