The exercise asks the program to read an N number and print out the N-numbered prime number. Ex: I enter with N = 3. The program will have to print The third prime number, that is 5. Other examples: N-esimo (2) = 3, N-esimo (5) = 11. I did the following: p>
void nesimo_primo(int n)
{
int a, primo, div, nesimo;
primo = 0;
a = 1;
if(n == 1)
nesimo = 2;
else
{
for(nesimo = 3; nesimo <= 1000; nesimo++)
{
for(div = 2; div <= nesimo/2; div++)
{
if(nesimo%div != 0)
primo++;
if(primo == 1)
a = a + 1;
}
if(a == n)
break;
}
}
printf("N-esimo(%d) = %d\n", a, nesimo);
}
I wonder if logic makes sense and what could be wrong for the program to not be working properly.