Hi all, I'm looking to generate prime numbers. the code starts with p=5, 'p' been a possible prime, then 'd' been the divisor of 'p' to check if it is a prime number or not. where 'x' just increments up changing the value of 'd'. when p/d has no remainders it then checks the value of d to see if it is/isn't equal to 1.

Code:

#include <stdio.h>
main()
{
int p,d,x;
printf("how many primes numbers do you want to find starting from 5?");
scanf("%d",&y);
p=5;
x=1;
start:
y--;
if(y>0)
{d=p-x;
if(p%d!=0)
{
x++;
d=p-x;
goto start;
}
else {if(d!=1)
{p++;
x=1;
goto start;}
else{ if(d=1)
{printf("%d", p);
p++;
x++;
goto start;}
}}
}
}

when i compile and run it. nothing. can't be that hard.

also if omit the else's, it would still behave the same way right?

Code:

#include <stdio.h>
main()
{
int p,d,x,y;
printf("how many primes numbers do you want to find starting from 5?");
scanf("%d",&y);
p=5;
x=1;
start:
y--;
if(y>0)
{d=p-x;
if(p%d!=0)
{
x++;
d=p-x;
goto start;
}
if(d!=1)
{p++;
x=1;
goto start;}
if(d==1)
{printf("%d", p);
p++;
x++;
goto start;}
}
}

am i doing something horribly wrong? :O