lundi 25 avril 2016

I cannot understand what does the line mean : public boolean[] functionName() in C++

I came across this function for implementing The Sieve of Erastosthenes on Topcoder member tutorials but I cant wrap my head around what is the purpose of public and boolean[].

Here is the code:

public boolean[] sieve(int n)
{
   boolean[] prime=new boolean[n+1];
   Arrays.fill(prime,true);
   prime[0]=false;
   prime[1]=false;
   int m=Math.sqrt(n);

   for (int i=2; i<=m; i++)
      if (prime[i])
         for (int k=i*i; k<=n; k+=i)
            prime[k]=false;

   return prime;
} 

Aucun commentaire:

Enregistrer un commentaire