Hey guys:

One of the assignment for class is Goldbach's conjecture. Below is my code, but I am having problems with the actually computation. It goes into an infinite loop when it prints the first conjecture which is 4 =2 +2. To me, it doesn't seem like my code would do that, but obviously it does.

Can someone help me out and figure out why it's going to an infinite loop?

Thanks

Code:

#include<stdio.h>

#include<stdbool.h>

bool is_prime(int );

void goldbach(int n, int m)

{

int i, j, k;

for(i=n; i<= m; i+2)

{

for(j=2; j<= m; j++)

{

if(is_prime(j))

{

for(k=2; k<= m; k++)

{

if(is_prime(k))

{

if( i == (j + k))

printf("%d = %d + %d\n", i, j, k);

}

}

}

}

}

}

bool is_prime(int j)

{

int divisor;

for(divisor = 2; divisor*divisor <= j; divisor++)

{

if(j % divisor == 0)

return false;

}

return true;

}

int main(void)

{

int i, j, n, m;

printf("\nEnter the value of n: ");

scanf("%d", &n);

printf("Enter the value of m: ");

scanf("%d", &m);

/* ********** SETS BOUNDRIES CORRECTLY ********** */

if(n < 4)

n = 4;

if((n % 2) != 0)

n = n + 1;

if((m % 2) != 0)

m = m - 1;

/* ********************************************* */

goldbach( n, m);

printf("\n");

return(0);

}