vici's blog

By vici, 14 years ago, In English
/*********************************
mark[]:p=0,c=1(except for evens); 
pri[]:p(0..cnt-1)
*********************************/
const int MAXP=10000000;
int pri[MAXP],cnt;
bool mark[MAXP];
int setp() {
    int i,j;
    cnt=1,pri[0]=2;
    for(i=3;i<MAXP;i+=2){
        if(!mark[i])pri[cnt++]=i;
        for(j=1;j<cnt && pri[j]*i<MAXP;++j){
            mark[i*pri[j]]=1;
            if(!(i%pri[j]))break;
        }
    }
    return cnt;
}
  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
14 years ago, # |
  Vote: I like it +4 Vote: I do not like it

What does "setPrimeNumbers" mean?

1) If "set" means "determine, esteblish", then, a more correct title may be "getPrimeNumbers", but not "set",because prime numbers are already exists and we can't "set" them :)

2) If "set" means "variety, data storage", then a more correct title may be "setOfPrimeNumbers" or "getSetOfPrimeNumbers".

In both cases, your title is very ambiguous. IMHO it's not good.