示例#1
0
//return how many lifing cels are around a position in field.
int totalAround(uint8_t *field, int position){
  int around = checkUpper(field, position)+checkLower(field, position)+checkLeft(field, position)+checkRight(field, position)+checkUpperLeft(field, position)+checkUpperRight(field, position)+checkLowerLeft(field, position)+checkLowerRight(field, position);
  return around;
}
示例#2
0
void checkComparisons(T low, T mid, T high) {
  checkEquals(mid, mid);
  checkGreater(mid, low);
  checkLower(mid, high);
}
示例#3
0
void goldbach(int n){
// finds the seg, int and bit for 3 and k-3 and passes them to methods that increment up and down in 2 different methods
int numCount = 0;
int k = 3;
int ktwo = n-3;
int goldCount = 0;
int targetNum1 = 0;
int targetNum2 = 0;
///////seg int and bit for 3
seg* segNum2 = whichseg(k);
int kintone = whichint(k);
int bit1 = whichbit(k);
///////seg in and bit for k-3
seg* segNum3 = whichseg(ktwo);
int kinttwo = whichint(ktwo);
int bit2 = whichbit(ktwo);

while (k <= n/2){
		
	if(checkLower(segNum2, kintone, bit1) && checkHigher(segNum3, kinttwo, bit2) == 1){
		goldCount += 1;
		targetNum1 = k;
		targetNum2 = ktwo;
		}

	//printf("%d %d\n", k, ktwo);

	//////////////////////////////////LOWER END LOGIC
	if(bit1 != 31){
		bit1 +=1;}
		
	else{
	bit1 = 0;
	kintone += 1;}

	if(kintone > 255 && segNum2->next !=NULL){
	kintone = 0;
	segNum2 = segNum2->next;}
	/////////////////////////////////////////////////
	//////////////////////////////////UPPER END LOGIC
	if(bit2 != 0){
		bit2 -=1;}

	else{
	bit2 = 31;
	kinttwo -= 1;}	
	
   	if( kinttwo < 0 && segNum3->prev != NULL){
	kinttwo = 255;
	segNum3 = segNum3->prev;
	}	
	/////////////////////////////////////////////////


	k += 2;
	ktwo -=2;

}
printf("\nThe last Goldbach decomposition is: %d + %d \n",  targetNum1, targetNum2 );
printf("The amount of decompositions is: %d \n", goldCount);	
	

}