+ 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..

1st Aug 2018, 3:39 PM
Mary
Mary - avatar
3 ответов
+ 3
Thanks for the help:)
1st Aug 2018, 10:51 PM
Mary
Mary - avatar
+ 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]); } }
1st Aug 2018, 3:49 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
happy to help
2nd Aug 2018, 1:28 AM
Ketan Lalcheta
Ketan Lalcheta - avatar