Integer fractorization in C language : I am making a program with C language to make the output look like this.

    2 = 2
    3 = 3
    4 = 2 x 2
    5 = 5
    6 = 2 x 3
    ....
    102 = 2 x 3 x 17
    103 = 103
    104 = 2 x 2 x 2 x 13

I wrote the integer fractorization code in this way.


    #include <stdio.h>
    #define MAXNUM 1000

    int main(){
	int num,numfordiv;
	int div = 2;
	for (num=2;num<MAXNUM;num++){
		printf("%d=", num);
		numfordiv = num;
		if(num%div != 0){
			div = div+1;
		}
		else{
			numfordiv = numfordiv / div;
			printf("%d x ",div);
			if(numfordiv == 1){
				div = 2;
			}
		}
	}
	return 0;
    }

However, this does not work for unknown reason. Is there anything wrong with the loop?