cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A276417 a(n) = least positive k such that (2*n + 1) - 2^k is prime, or 0 if no such k exists.

Original entry on oeis.org

0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 4, 1, 1, 2, 3, 1, 2, 1, 1, 2, 1, 2, 4, 1, 2, 4, 1, 1, 2, 3, 1, 2, 1, 1, 2, 3, 1, 2, 1, 2, 4, 1, 2, 4, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 4, 3, 4, 4, 0, 1, 2, 1, 2, 6, 1, 1, 2, 3, 3, 0, 1, 1, 2, 3, 1, 2, 5, 1, 2, 1, 2, 4
Offset: 0

Views

Author

Arkadiusz Wesolowski, Sep 02 2016

Keywords

Comments

a(n) = 1 iff n is in A006254. - Robert Israel, Sep 02 2016
For n > 1, a(n) = 0 iff 2n+1 is de Polignac number, A006285. - Thomas Ordowski, Apr 13 2017

Examples

			a(14) = 4 because (2*14 + 1) - 2^k is composite for k = 1, 2, 3 and prime for k = 4.
		

Crossrefs

Programs

  • Magma
    lst:=[]; for n in [1..173 by 2] do k:=0; c:=k; repeat k+:=1; c+:=1; a:=n-2^k; until a lt 1 or IsPrime(a); if a lt 1 then Append(~lst, 0); else Append(~lst, c); end if; end for; lst;
    
  • Maple
    f:= proc(n) local k;
         for k from 1 do
           if 2*n < 2^k then return 0
           elif isprime(2*n+1-2^k) then return k
           fi
         od
    end proc:
    map(f, [$0..100]); # Robert Israel, Sep 02 2016
  • Mathematica
    Table[If[n <= 2, 0, k = 1; While[! PrimeQ[2 n + 1 - 2^k], k++]; k], {n, 0, 120}] (* Michael De Vlieger, Sep 03 2016 *)
  • PARI
    a(n) = my(k=1); while(2^k < 2*n+1, if(ispseudoprime((2*n+1)-2^k), return(k)); k++); return(0) \\ Felix Fröhlich, Sep 02 2016

Formula

If A188903(n) >= 2, then a(n) = log_2(A188903(n)), otherwise a(n) = 0.