This commit is contained in:
2026-06-02 09:43:01 +02:00
parent fba92ac2b2
commit 15cf9ffa94
6 changed files with 107 additions and 1 deletions

46
test_computation.c Normal file
View File

@@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
int main(void) {
FILE *file1 = fopen("input.bin", "rb");
if (!file1) {
perror("Error opening input.bin");
return 1;
}
int n;
if (fread(&n, sizeof(n), 1, file1) != 1) {
perror("Error reading input.bin");
fclose(file1);
return 1;
}
fclose(file1);
printf("Got: %d\n", n);
// Primes or smth
int count = 0;
for (int i = 2; i < 500000; i++) {
int prime = 1;
for (int d = 2; d * d <= n; d++) {
if (n % d == 0) {
prime = 0;
break;
}
}
count += prime;
n += 2;
}
FILE *file2 = fopen("output.bin", "wb");
if (!file2) {
perror("Error opening output.bin");
return 1;
}
fwrite(&count, sizeof(count), 1, file2);
fclose(file2);
return 0;
}