There is a famous mathematical conjecture called the Goldbach conjecture, that every even integer greater than 2 has the property that it is the sum of two prime integers. Write a C program that will prove that this conjecture is true for even numbers between a START value and a FINISH value. For example, if START = 700 and FINISH = 800 the initial output of your program would be:

700 = 17 + 683
702 = 11 + 691

The values of START and FINISH are to be supplied by command line arguments.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have this but theres a problem with a loop somwhere cuz when run it just stays blank

int isPrime(int i);
int main(int argc, char *argv[]){
  int start = atoi(argv[1]), finish = atoi(argv[2]);
  int i = start, j = 0, k;

  while(i <= finish){
    k = i - 1;

    do {
      j = j + 1;
      k = k - 1;
    } while( j + k != i);

    do {
      if((isPrime(j) == 1) && (isPrime(k) == 1)) printf("\n%d = %d + %d", i, k, j);
      i = i + 2;
    } while( j + k == i);
  }
  return(0);
}
int isPrime(int i){
  int j, count = 0;

  for(j = 1; j <= i; j++){
    if((i % j) == 0) count++;
  }

  return(count == 2);
}

any help within an hour would be greatly appreciated

>I have this[,] but theres a problem with a loop som[e]where[,] [because] when [it] run[s][,] it just stays blank[.]

You created a nice forever loop.

do {
      j = j + 1;
      k = k - 1;
    } while( j + k != i);/* never true, since j+k will always be the same value */
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.