Skip to content

Commit

Permalink
Merge pull request #350 from dallasGeorge/master
Browse files Browse the repository at this point in the history
added a goldbach conjectture C program
  • Loading branch information
simranlotey authored Dec 28, 2023
2 parents a63a0c1 + a5cc8c5 commit 7fe020d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions C/goldbach_conjecture.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


#include <stdio.h>

int main()
{
unsigned long long int n,flag,q,jj,flag2,i,j;
scanf("%llu",&n);
if (n<=2||n%2!=0){
printf("Wrong Input");
}
else{
for(i=2;i<=n;i++){
flag=1;
for (j=2;j<i;j++){
if(i%j==0 && i!=j){
flag=0;
break;
}
}
if(flag==1){
flag2=1;
q=n-i;
for (jj=2;jj<q;jj++){
if(q%jj==0 && q!=jj){
flag2=0;
break;
}
}
if (flag2==1){
printf("%llu+%llu=%llu",i,q,n);
break;
}
}
}
}
return 0;
}

0 comments on commit 7fe020d

Please sign in to comment.