Skip to content

Instantly share code, notes, and snippets.

@Silur
Created January 2, 2020 00:31
Show Gist options
  • Save Silur/da09e308099b52d7017a0e7989867f9d to your computer and use it in GitHub Desktop.
Save Silur/da09e308099b52d7017a0e7989867f9d to your computer and use it in GitHub Desktop.
check for numbers that for conference matrices surely exist
#include <gmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
static int prime_or_power(mpz_t c_1, int log2, mpz_t *rop)
{
if (mpz_probab_prime_p(c_1, 100) != 0) return 1;
int i;
for(i=1; i<log2; i++)
{
if (mpz_root(*rop, c_1, i) == 0) continue;
if(mpz_probab_prime_p(*rop, 100) != 0) return 1;
}
return 0;
}
int main(int argc, char **argv)
{
int from = atoi(argv[1]);
int to = atoi(argv[2]);
printf("checking from %d to %d\n", from, to);
mpz_t c, c_1, rop;
mpz_inits(c, c_1, rop, 0);
unsigned int i;
for(i=from; i<to; i++)
{
mpz_set_ui(c, i);
if(mpz_fdiv_ui(c, 4) != 2) continue;
mpz_sub_ui(c_1, c, 1);
if(prime_or_power(c_1, (int)ceil(log2(i)), &rop) == 0) continue;
printf("%d\n", i);
}
mpz_clears(c, c_1, rop, 0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment