+ 2
help needed with c code [Solved]
https://code.sololearn.com/cBmOfvQaqv6W/#c Goldbach's conjecture code won't work properly. The prime numbers seem okay. Maybe something's wrong with the array I'm not sure..
3 Answers
+ 3
Thanks for the help:)
+ 2
you cannot loop till prime[count] as it is 47 in case user entered number as 50... So, you have definitely less numbers then 47 in array and you are going from i as 3 to 47... it should be as below:
for(i=0;i<=count;i++){
for(j=0;j<=count/2;j++){
if((prime[i]+prime[j])==input)
printf("%d+%d\n",prime[i],prime[j]);
}
}
+ 2
happy to help