Guest User

Connectibles

a guest
Jan 30th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <gmp.h>
  3.  
  4. int main(void)
  5. {
  6.     mpz_t x;
  7.     mpz_init(x);
  8.     mpz_set_ui(x,18);
  9.     int i;
  10.     for(i=0;i<50;++i){
  11.         mpz_mul_2exp(x,x,1);mpz_sub_ui(x,x,1);//x->2x-1
  12.         int last = 0;
  13.         while(1){//BEWARE!
  14.             int current=mpz_probab_prime_p(x,30);//The probability of a pseudoprime is (1/4)^30
  15.             if(current&&last)break;//Miller-Rabin probabilistic test
  16.             last=current;
  17.             mpz_sub_ui(x,x,2);
  18.         }
  19.         mpz_add_ui(x,x,1);//x and x+2 are primes,so we set x->x+1
  20.     }
  21.     gmp_printf("%Zd\n",x);
  22.     mpz_clear(x);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment