Program:-
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int arr[10003];
arr[1]=2;
int n, i = 3, count, c;
for ( count = 2 ; count <= 10003 ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
arr[count]=i;
count++;
}
i++;
}
int temp;
scanf("%d",&temp);
for(int i=0;i<temp;i++)
{
scanf("%d",&n);
printf("%d\n",arr[n]);
}
return 0;
}
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int arr[10003];
arr[1]=2;
int n, i = 3, count, c;
for ( count = 2 ; count <= 10003 ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
arr[count]=i;
count++;
}
i++;
}
int temp;
scanf("%d",&temp);
for(int i=0;i<temp;i++)
{
scanf("%d",&n);
printf("%d\n",arr[n]);
}
return 0;
}