#include #include int main() { int eingabe; int *zahlenBisN = (int *)malloc(100 * sizeof(int)); do { printf("%s", "Bis wohin sollen die Primzahlen berechnet werden (Ende=0) ? "); scanf("%d", &eingabe); if(eingabe > 100) { free(zahlenBisN); zahlenBisN = (int *)realloc(zahlenBisN, eingabe * sizeof(int)); } for (int i = 0; i < eingabe; ++i) { zahlenBisN[i] = i+1; } for (int i = 0; i < eingabe; ++i) { for (int j = 2; j < i; j++ ) { if (zahlenBisN[i] % j == 0) { zahlenBisN[i] = 0; } } } for (int i = 1; i < eingabe; ++i) { if(zahlenBisN[i] != 0) { printf("%10d", zahlenBisN[i]); } } printf("\n"); }while(eingabe != 0); free(zahlenBisN); }