From fd3700c96040bb7819ae342066135b4fc4431959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hatvani=20Tam=C3=A1s?= Date: Tue, 14 Apr 2026 09:01:53 +0200 Subject: [PATCH] random generator optimization for primes --- helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helper.c b/helper.c index d824b50..0e2300b 100644 --- a/helper.c +++ b/helper.c @@ -2,7 +2,7 @@ #include #include -uint32_t rand32() { return (rand() << 16) | (rand() & 0xFFFF); } +uint32_t rand32() { return (rand() << 16) | (rand() & 0xFFFF) | 1; } void print_uint128(unsigned __int128 n) { if (n == 0) { @@ -32,6 +32,9 @@ uint64_t rand64() { for (int i = 0; i < 4; i++) { r = (r << 16) | (rand() & 0xFFFF); } + + // Force the bottom bit to 1, this will make all generated primes odd + r = r | 1; return r; }