Miller-rabin primality test for orders of magnitude lower computational complexity

This commit is contained in:
Imbus 2025-02-12 20:37:45 +01:00
parent 28209ca70e
commit 2c7904d2b3
3 changed files with 58 additions and 2 deletions

14
main.c
View file

@ -41,6 +41,20 @@ int main() {
uint64_t n = p * q;
int before = SysTick->CNT;
bool check_a = miller_rabin(p, 10);
int miller = SysTick->CNT - before;
before = SysTick->CNT;
bool check_b = is_prime(p);
int isprime = SysTick->CNT - before;
printf("Is prime: %s %s\n", check_a ? "true" : "false",
check_b ? "true" : "false");
printf("Miller took %d ticks\n", miller);
printf("Is_prime took %d ticks\n", isprime);
// Make these work by patching printf
printf("P: %u\n", (uint32_t)p);
printf("Q: %u\n", (uint32_t)q);