#include #include #pragma pack(push, 1) #define N 100 struct bool_store { int v : 1; }; static struct bool_store _a[N - 1]; #pragma pack(pop) int A_bf2_get(int i) { if (i < 2) return 0; return _a[i - 2].v; } void A_bf2_set(int i, int b) { _a[i - 2].v = b; } #define TRUE 1 #define FALSE 0 void doSE() { int i; for (i = 2; i <= N; i++) A_bf2_set(i, 1); for (i = 2; i <= sqrt(N); i++) if (A_bf2_get(i)) { int j; for (j = i * i; j <= N; j += i) A_bf2_set(j, FALSE); } } #define FILL_CHAR '-' void do_and_print_eratostenes() { doSE(); int i; for (i = 0; i <= N; i++) { if (i % 10 == 0) putchar('\n'); putchar(' '); if (A_bf2_get(i)) printf(" %2d", i); else { if (i >= 100) putchar(FILL_CHAR); else putchar(' '); if (i >= 10) putchar(FILL_CHAR); else putchar(' '); putchar(FILL_CHAR); } } putchar('\n'); } void do_and_print_mersenne() { } int main() { do_and_print_eratostenes(); do_and_print_mersenne(); return 0; }