Hi everyone,
i have this code for the PRIME1 challenge :
#include <stdio.h>
int is_first(int x)
{
for (int z = 2; z <= x / 2; z++)
if (x % z == 0)
return (0);
return (1);
}
int main()
{
int t, first, last;
scanf("%d", &t);
while (t–) {
scanf("%d %d", &first, &last);
int i = first - 1;
while (++i <= last)
if (is_first(i) == 1 && i != 1)
printf("%d\n", i);
if (t != 0)
printf("\n");
}
return (0);
}
Do you know a way of testing this with real sample from spoj ?
I can’t figure out why i TLE …
Thanks for your help !