Trying to make a program that returns a set of prime numbers that equal an even integer between 700 and 1200. Supposed to define START as 700 and FINISH as 1100. Basically I'm stuck because it's not working at all.
Code:
#include<stdio.h>
int numPrime(int num);
int goldBach();
int main()
{
goldBach();
}
int goldBach(void)
{
int i, j, k, l=700, m=1100, ans;
for(i=l; i<=m; i++){
for(j=i; j>2; j--){
ans=numPrime(j);
if(ans!=0){
k=j-l;
ans=numPrime(k);
}if(ans!=0){
if( i == (j + k)){
printf("%d = %d + %d\n", i, j, k);
}
}
}
}
}
int numPrime(int num)
{
static int i=2; /* i initialized as static because it has to remain stored as +1 in recursive call, took me awhile to realize why it was freezing */
if(i<=num){ /* if 2 is less than number and number/i has 0 remainder then return 0 else add 1 to i and call the function again. */
if(num%i==0)
return 0;
else{
i++;
numPrime(num);
}
}
i=2;
return 1;
}