Generation method of simplest set of prime numbers satisfying Goldbach conjecture (C++)

Posted by EnDee321 on Thu, 23 Dec 2021 15:47:38 +0100

The sparsest set of prime numbers that satisfy Goldbach's conjecture is generated. There is also a simplest set generator that satisfies the Goldbach Conjecture Effect, which does not require a prime number.

The Goldbach conjecture effect refers to the generation of a final set of numbers from a set M that belongs to an equidistant set M (or an equidistant extension of an equidistant set M). ε, Make use of only the final set of numbers ε By adding two or two and dividing two, the whole set of large numbers M can be covered. We claim that the number set M satisfies the Goldbach conjecture effect on most sets M.

//'belongs to... Equidistant Expansion'is designed to facilitate the study of a segment of an infinite set.

The prime set M satisfies the Goldbach conjecture effect on the non-1 positive integer set M. The final set of numbers generated in this relationship ε:

Within 100,000, there are 9592 prime numbers.

But even numbers within 100,000 can satisfy Goldbach's conjecture with only 805 prime numbers.

Visible enough ε Much more sparse.

Perception studies the survivability of this simplest set generator: which set M is the final set ε, There is a certain density requirement for the original set m, otherwise the "effect" is not satisfied for most sets M. Feeling this has great significance in solving Goldbach's conjecture.

It can also be extended to ring set M, closed set M, and original set M when two-way infinite set M.

----------------------------------------

In order to prove Goldbach's conjecture,

It is necessary to study exactly how to get m which satisfies Goldbach's conjecture effect for non-1 positive integer set M in order to make the generator take out valid ε. (Equidistant single infinite set M is simplest ε Generator has generality).

This leads to the "law" of m, which can be written QED to Goldbach's conjecture by proving that the set of prime numbers meets this "law".

----------------------------------------

For any number of N,m must have a value from N+1 to 2N. Otherwise N cannot be paved out.

----------------------------------------

<GeoGuess Extrapolation Extrapolation Extrapolation Minimal Set Generator 4.0> (including solutions to achieve complete simplicity in special cases)

Emission of 2N prime star fills N (non-1 positive integer is M, prime is m,star is M) ε)

//Express the entire 1 axis, set 3,5 to star, flag=1 for label 3,5, because (3+5)/2==4, flag=4 is 1, 
//From four to six flag s are found to be zero,

//To be able to generate, use 3,5 to generate table={9,7}, which intersects the set of prime numbers to {7}, starting with 7.
//7 is progressively divided by 2 as (3+7)/2==5 its flag==1, so waste++ of 7,
//Because 7 has the smallest waste s, pick=7, making 7 a new star; 
//Flag=1 for label 7; Because (3+7)/2==5, flag=1 for label 5; because (5+7)/2==6, falg=1 for label 6;
//flag from 6 to 8 is 0,

//To be able to generate, table={13, 11, 9} is generated with 3, 5, 7, and {13, 11} is intersected with a prime number, selected from 13.
//13 is progressively divided by 2 with the previous star because there is no flag==1, so waste=0 for 13; 
//11 is progressively divided by 2 with the previous star because (3+11) /2==7 has flag==1, so 11 has waste+,
//Because 13 has the smallest waste s, pick=13, making 13 a new star;
//Flag=1 for label 13; Flag=1 for label 8 because (3+13)/2==8; flag=1 for label 9 because (5+13)/2==9; flag=1 for label 10 because (7+13)/2==10; 
//From 8 to 11 flag s are found to be zero,


//To be able to generate, use 3, 5, 7, 13 to generate table={15, 13, 9} (note that its elements are larger than Mstar), select from 15,...

#include<bits/stdc++.h>
using namespace std;
#define N 50000



bool cmp(int a, int b){
	return a>b;
}

//Prime number generation 
int arr[2*N]={2,3,5};
int p_len=3;
void primenum(int n, int arr[]);

bool flag[2*N]={0};//Whether the number can be generated from the beginning;
int star[N]={0};
int main(){
	primenum(N, arr);
	
	star[0]=3;
	flag[3]=1;
	
	star[1]=5;
	flag[5]=1;
	
	int len=2;//star length; 
	int Mstar=5;//MAX star;
	
	for(int i=0;i<len-1;i++){
			flag[(star[i]+Mstar)/2]=1;
	}
	int n=6;//n denotes the minimum number of previous flag=0;
	
	while(n<=N){
		
		int table[N]={0};
		int l1=0;//Length of table s when they do not intersect prime numbers 
		int l=0;//Final table length
		int waste[N]={0};//Corresponds to table, indicating the value of the table's selection; 
		for(;l1<len;l1++){
			table[l1]=(2*n-star[l1]);
		}
		
		l=l1;
		bool flag2[N]={0};//Corresponds to a table that does not intersect a prime number to indicate whether it appears or not; 
		for(int i=0;i<l1;i++){
			for(int j=0;arr[j]<2*n;j++){
				if(arr[j]==table[i]) flag2[i]=1;
			}
			if(flag2[i]==0) {
				table[i]=0;
				l--;
			}
		} 
		sort(table,table+l1,cmp);
		
		for(int i=0;i<l;i++){
			for(int j=0;j<len;j++){
				if(flag[(table[i]+star[j])/2]==1) waste[i]++;
			} 
		}
		int pick=0;
		for(int i=1;i<l;i++){
			if(waste[pick]>waste[i]) pick=i;
		}
		
		star[len++]=table[pick];
		flag[table[pick]]=1;
		if(table[pick]>Mstar) Mstar=table[pick];
		sort(star,star+len);
		
		
		for(int i=0;i<len;i++){
			flag[(star[i]+table[pick])/2]=1;
		}
		for(int i=n;;i++){
			if(flag[i]==0){
				n=i;
				break;
			}
		}
	}
	printf("\nstar sequence:\n");
	for(int i=0;star[i]!=0;i++){
		printf("%d ",star[i]);
	}

	printf("\n Numbers that cannot be filled:%d",n);
	printf("\nstar Length:%d",len);
	printf("\nstar Sequence Interval:\n");
	for(int i=1;star[i]!=0;i++){
		printf("%d ",(star[i]-star[i-1])/2);
	}
	printf("\n\n");
	for(int i=0;i<N;i++){
		printf("%d ",flag[i]);
	}

	

}
	





void primenum(int n, int arr[]){
    for(int i=6;i<2*n;i++){//Generate prime numbers starting at 6
        bool flag= true;
        for(int j=0;arr[j]<=sqrt(i);j++){
            if(i % arr[j] ==0){
                flag=false;
                break;
            }
        }
        if(flag == true){
        	p_len++;
        	arr[p_len-1]=i;
    	}
	}
	printf("Number of prime numbers:%d\n", p_len);
	for(int i=0;i<p_len;i++){
		printf("%d ",arr[i]);
	}
	printf("\n");
	
	
}




//Potential collapse: the first small of the logarithms of an n is not selected for the generated sequence,
//In order to solve this problem and keep it simplest, you should find pairs in m when they do not exist.
//Perform one more step of the search from scratch in m, and if found, start again at its smaller M.






Topics: C++ Algorithm