what do you you mean, this prog doesnt work??

someone asked earlier about a program involving prime numbers, and i figured they would be pretty easy to work with, so i threw together a simple program to show all of the prime numbers less than 1000. this program looks like it should run perfectly from what i see, but it seems that it comes up with no results at all.

my program looks like this:

#include <stdio.h>

#include <stdlib.h>

void prime();

int i=1000,x=0,y,z;

void main(){

printf("All of the prime numbers less than 1000:\n");

while ( i > 2 ){

z=0;

x=i;

prime();

i = --i;

}

printf("2\n1\n");

system ("PAUSE");

}

void prime (){

while ( x != 1 ){

y = i % (x-1);

x = --x;

if ( y == 0 ){

x = 1;z = 1;}

}

if ( z == 0 ){

printf("%d\n", i); }

}

and the output looks like this:

All of the prime numbers less than 1000:

2

1

press any key to continue...

the prime() function is supposed to check for divisibility in every number below i. if any number divides evenly then it sets z to 1. if z never gets set to 1, and x gets all the way to 1, it prints i and then subtracts one from i and repeats the loop. why doesnt this ever print anything?