1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
long Nombre[1000] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 0};
long Index = 0;
long NbActuel = 0;
int Temp = 0;
printf("Ce programme calcule en temps r%cel les nombre premier:\n", 0x82);
printf("2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, ");
while (1)
{
Prochaine:
while (Nombre[Index] != 0)
{
Temp = NbActuel % Nombre[Index];
if (Temp == 0)
{
goto Next;
}
Temp = 0;
Index++;
if ((Nombre[Index] == 0) || (Index < 1000))
{
goto Next;
}
}
if (Nombre[Index] == 0)
{
goto Next;
}
printf("%ld, ", NbActuel);
Nombre[Index] = NbActuel;
Next:
Temp = 0;
NbActuel++;
Index = 0;
goto Prochaine;
}
system("PAUSE");
return 0;
} |
Partager