VB icon

Confirmation of Goldbach's conjecture

Email
Submitted on: 9/24/2015 7:12:06 AM
By: Boris Sklyar  
Level: Advanced
User Rating: Unrated
Compatibility: C++ (general)
Views: 2940
 
     Program calculates two prime numbers Pr1 and Pr2 sum of which equals any given even number N=Pr1+Pr2

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Confirmation of Goldbach's conjecture
// Description:Program calculates two prime numbers Pr1 and Pr2 sum of which equals any given even number
N=Pr1+Pr2
// By: Boris Sklyar
//**************************************

#include <cstdlib> 
#include <iostream>
#include <math.h>
#include <ctime>
using namespace std;
 main( ) 
{
/* PROOF OF GOLDBACH CONJECTURE*/
 /*CALCULATING PRIMES, SUM OF TWO PRIMES EQUALS GIVEN EVEN NUMBER N<5*10^19*/
 /*N=Pr1+Pr2*/
 
 
						 
 unsigned long long int N=43255817073339528; int nd=3000;
 if (N<1000000) nd=300;
 if (N<1000) nd=150;
unsigned long long int N1=N/2-nd; unsigned long long int N2 =N1+2*nd;
unsigned long long int p1=floor(N1/6); unsigned long long int p2=ceil( N2/6);
 int r=84000; int R2[r]; int rm=p2-p1;unsigned long long int S2[r];int r3, r4, v, k;
 int q=84000; int R1[q] ; int qm=rm; unsigned long long int S1[q], Q1, Q2, Ne, Nd, Nd1, Nd2; int q2, q1;
 for (q=1;q<qm;q++) 
 R1[q] =1;
 for (r=1;r<rm;r++) 
 R2[r] =1;
unsigned long long	int i, j, P1, P2, P3, P4, B, K;
	unsigned long long	int i2= sqrt( p2/6)+2;
long long int j1, j2;	
 	int l1=0;int l2=0;
float m1=(long double ) (N-10)/6-(N-10)/6;
float m2=(long double ) (N-12)/6-(N-12)/6;
float m3=(long double ) (N-14)/6-(N-14)/6;
	for ( i=1;i<i2;i++)
	{ j2=(p2+i+1)/( 6*i+1)+1;j1=(p1+i+1)/( 6*i+1);
	B=5+5*( i-1); K=7+6*( i-1);
	if ( i>j1) j1=i;
 	for(j=j1; j<j2;j++)
{	 P1=B+K*( j-1);
	if(( P1>p1)&&( P1<p2)) 
	{ q1=P1-p1; R1[ q1] =0;
} }
j2=(p2-i+1)/( 6*i-1)+1;j1=(p1-i+1)/( 6*i-1);
if (j1<1) j1=1;
	B=5+7*( i-1); K=5+6*( i-1);
 if ( i>j1-1) j1=i+1;
 	for(j=j1; j<j2;j++)
{	 P2=B+K*( j-1);
	 
 if(( P2>p1)&&( P2<p2))
{ q2=P2-p1; R1[ q2] =0;
 } }
 j2=(p2+i+1)/( 6*i-1)+1;j1=(p1+i+1)/( 6*i-1);
B=3+5*( i-1); K=5+6*( i-1);
if ( i>j1) j1=i;
	for(j=j1; j<j2;j++)
{	P3=B+K*( j-1); 
if(( P3>p1)&&( P3<p2))
{ r3=P3-p1; R2[ r3]=0;
 } } 
j2=(p2-i+1)/( 6*i+1)+1;j1=(p1-i+1)/( 6*i+1);
B=7+7*(i-1); K=7+6*(i-1);
	if ( i>j1) j1=i;
		for(j=j1; j<j2;j++)
{ P4=B+K*( j-1);	 
if(( P4>p1)&&( P4<p2)) 
{ r4=P4-p1; R2[ r4] =0;
} } }
 for ( q=1;q<qm;q++) { S1[q] =R1[q]*((p1+q)*6+5); if (S1[q]%5==0) continue; l1=l1+1;}
 for ( r=1;r<rm;r++) { S2[r] =R2[r]*((p1+r)*6+7);if (S2[r]%5==0) continue;l2=l2+1;}
 
if (m1==0){ cout<<"N belongs to the sequence N=6p+10; m1="<<m1<<" \n\n";
	for (v=1;v<1000;v++) {
	 Q1=S1[v];
	 for (k=1;k<1000;k++) {
	 Q2=S1[k]; Ne=Q1+Q2;
	
			if (Ne==N){Nd=N; Nd1=Q1;Nd2=Q2;
			
	
	break;}}}}
	 
	 if (m2==0){ cout<<"N belongs to the sequence N=6p+12; m2="<<m2<<" \n \n";;
	for (v=1;v<1000;v++) {
	 Q1=S1[v];
	 for (k=1;k<1000;k++) {
	 Q2=S2[k]; Ne=Q1+Q2;
	
			if (Ne==N){Nd=N; Nd1=Q1;Nd2=Q2;
			
	
	break;}}}}
	
	 if (m3==0){ cout<<"N belongs to the sequence N=6p+14; m3="<<m3<<" \n \n";
	for (v=1;v<1000;v++) {
	 Q1=S2[v];
	 for (k=1;k<1000;k++) {
	 Q2=S2[k]; Ne=Q1+Q2;
			if (Ne==N){Nd=N; Nd1=Q1;Nd2=Q2;
			
	
	break;}}}}
	 cout<<" N=Pr1+Pr2="<<Nd<<"; Pr1="<<Nd1<<"; Pr2="<<Nd2<<"; \n\n";
	 
	 	cout<<"run time(ms)="; cout<<clock();
 system("PAUSE");
 return EXIT_SUCCESS;
 
}
 


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.