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.

Showing 1-2 of 2 results.

A252168 Smallest k > 0 such that |(2n-1) - 2^k| is prime, or -1 if no such k exists.

Original entry on oeis.org

2, 3, 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, 47, 1, 2, 1, 2, 6, 1, 1, 2, 3, 3, 8, 1, 1, 2, 3, 1, 2, 5, 1, 2, 1, 2, 4
Offset: 1

Views

Author

Eric Chen, Dec 14 2014

Keywords

Comments

It is known that a(254602) = -1, because |509203-2^k| is always divisible by 3, 5, 7, 13, 17, or 241. a(1147) is the first unknown term.
a((A101036(n)+1)/2) = -1, so there are infinitely many n such that a(n) = -1.
a((A133122(n)+1)/2) = A096502((A133122(n)-1)/2).

Examples

			a(12) = 2 because 2*12-1 = 23 and that 23-2^1 = 21 is not prime but 23-2^2 = 19 is.
a(69) = 6 because 2*69-1 = 137, |137-2^k| is composite for k = 1, 2, 3, 4, 5 and prime for k = 6.
Even the smallest k can be also very large. For example, a(169) = 791.
a(1147) > 65536.
		

Crossrefs

Programs

  • Mathematica
    Table[k = 1; While[!PrimeQ[Abs[(2*n-1) - 2^k]], k++]; k, {n, 1, 1000}]
  • PARI
    A252168(n)={ my(k=1); n=2*n-1; while(!ispseudoprime(abs(n-2^k)), k++); k }

Extensions

a(19) corrected by Jinyuan Wang, Mar 25 2023

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.
Showing 1-2 of 2 results.