A281571 Smallest k such that (the base-2 number formed by concatenating k consecutive base-2 numbers starting at n) is prime, or 0 if no such k exists.
15, 1, 1, 2, 1, 26, 1, 2, 31
Offset: 1
Examples
a(1) = 15 because we have to concatenate the base-2 numbers from 1 to 15 to reach the first prime. In fact concat(1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111) = 1101110010111011110001001101010111100110111101111, which is prime (in base 10 it is 485398038695407).
Links
- Paolo P. Lava, First 100 terms (with -1 if a(n) is not presently known)
Programs
-
Maple
P:=proc(q) local a,b,k,n; for n from 1 to q do if isprime(n) then print(1); else a:=convert(n,binary,decimal); for k from n+1 to q do b:=convert(k,binary,decimal); a:=a*10^(ilog10(b)+1)+b; if isprime(convert(a,decimal,binary)) then print(k-n+1); break; fi; od; fi; od; end: P(10^10);
-
Mathematica
With[{nn = 2^10}, Table[Module[{k = n, w = IntegerDigits[n, 2]}, While[And[! PrimeQ[FromDigits[w, 2]], k - n < nn], k++; w = Join[w, IntegerDigits[k, 2]]]; If[k - n >= nn, -1, k - n + 1]], {n, 50}]] (* Michael De Vlieger, Apr 26 2017, with -1 indicating values of k > limit nn *)
-
PARI
a(n,c=1,m=n)=while(!ispseudoprime(n),c++;n=n<<#binary(m++)+m);c
Formula
a(n) = 1 if n is prime.
Extensions
Edited by Max Alekseyev, Apr 26 2017.
Further edits from N. J. A. Sloane, Apr 26 2017
a(18) = 586, a(28) = 934, a(35) = 947, a(51) = 1325 (PRP), and further edits from M. F. Hasler, Apr 26 2017
Comments