Treceți la conținutul principal

Postări

Se afișează postări din august, 2017

program nr prime pseudocod netestat

int [] nonprime20= {4,6,8,9,10,12,14,15,16,18,20};
int [] prime20={1,2,3,5,7,11,13,17,19};


int isPar(int nr){
  if(nr%2==0){return 1;}
else {return 0;}
}


int isImpar(int nr){
    if(nr%2!=0){return 0;}
else {return 1;}
}

int firstRightNr(int nr){
  return nr%10;
}

int isThisNrPrim(int n){
int  i;
int s= sqrt(n);
//we will verify just the odd numbers except 5
//the even numbers and 5 we have verify all ready before 
for (i=3; i< =s; i+=2){
 if((firstRightNr(nr)==5)&&(i<=s)){ i+=2;}//3 +2 will never be x0
 if(n%i==0) {  return 0; } //nu e prim 
else{ return 1; }//e prim
}
}

int howManyDigitsHave(int n){
    int nr = n;
int counter = 0;
while(nr){ 
nr=nr/10;
counter ++;
 }
return counter;
}


int singleDigitNumber(int n){
//will never be 11
if(n==11){return -1;} //we just say before 11 is prime
    int howlong = howManyDigitsHave();
    int curentDigit,firstDigit;
firstDigit = n%10;
for(int i = 1;i<=howlong;i++){
curentDigit = n%10;
n=n/10;
if( curentDigit!=firstDigit) {return 0;}
}
return 1;
}
int isPrim(int nr){
 if(…

NUMERE PRIME ALGORITM C++

// NUMERE PRIME ALGORITM C++//  reediting from scratch //on this page is just the study for a next algoritm for generating the parime nr series like Fibonnaci or ....if possibile

74111121313417374414124343447 if u know the red part you can generate the orange part
1 0 1 111112222 1 1 23