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-9 of 9 results.

A117405 Semiprime nearest to 2^n. (In case of a tie, choose the smaller).

Original entry on oeis.org

4, 4, 4, 9, 15, 33, 65, 129, 254, 511, 1027, 2047, 4097, 8193, 16382, 32765, 65531, 131073, 262142, 524289, 1048577, 2097149, 4194311, 8388607, 16777219, 33554429, 67108867, 134217731, 268435457, 536870918, 1073741821, 2147483649, 4294967297, 8589934589
Offset: 0

Views

Author

Jonathan Vos Post, Mar 13 2006

Keywords

Comments

Semiprime analog of A117387 Prime nearest to 2^n. (In case of a tie, choose the smaller). After n=2, never again is a(n) a power of 2.

Examples

			a(0) = 4 because 2^0 + 3 = 4 = A001358(1) and no semiprime is closer to 2^0.
a(1) = 4 because 2^1 + 2 = 4 = A001358(1) and no semiprime is closer to 2^1.
a(2) = 4 because 2^2 + 0 = 4 = A001358(1) and no semiprime is closer to 2^2.
a(3) = 9 because 2^3 + 1 = 9 = 3^2 = A001358(3), no semiprime is closer to 2^3.
a(4) = 15 because 2^4 - 1 = 15 = 3 * 5 and no semiprime is closer.
a(5) = 33 because 2^5 + 1 = 33 = 3 * 11 and no semiprime is closer to 2^5.
a(6) = 65 because 2^6 + 1 = 65 = 5 * 13 and no semiprime is closer to 2^6.
a(7) = 129 because 2^7 + 1 = 129 = 3 * 43 and no semiprime is closer to 2^7.
a(8) = 254 because 2^8 - 2 = 254 = 2 * 127 and no semiprime is closer to 2^8.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Catch@Block[{p = 2^n, k = 0}, While[True, If[p > k && PrimeOmega[p - k] == 2, Throw[p - k]]; If[PrimeOmega[p + k] == 2, Throw[p + k]]; k++]]; a /@ Range[20] (* Giovanni Resta, Jun 15 2016 *)

Formula

a(n) = 2^n + A117406(n).

Extensions

Corrected and extended by Giovanni Resta, Jun 15 2016

A117406 Integer k such that 2^n + k = A117405(n).

Original entry on oeis.org

3, 2, 0, 1, -1, 1, 1, 1, -2, -1, 3, -1, 1, 1, -2, -3, -5, 1, -2, 1, 1, -3, 7, -1, 3, -3, 3, 3, 1, 6, -3, 1, 1, -3, -3, -3, -3, -1, 18, 3, 1, -1, 3, 1, -3, 3, 7, -9, 3, -1, 7, -5, 3, 11, -3, -5, 6, -9, -3, -1, -3, 1, -2, 9, 1, 5, 3, -1, -5, -13, 9, -3, -7, -3
Offset: 0

Views

Author

Jonathan Vos Post, Mar 13 2006

Keywords

Comments

After n=2, never again is a(n) = 0. Semiprime analog of A117388 Integer k such that 2^n + k = A117387(n). A117387(n) is prime nearest to 2^n. (In case of a tie, choose the smaller).

Examples

			a(0) = 3 because 2^0 + 3 = 4 = A001358(1) and no semiprime is closer to 2^0.
a(1) = 2 because 2^1 + 2 = 4 = A001358(1) and no semiprime is closer to 2^1.
a(2) = 0 because 2^2 + 0 = 4 = A001358(1) and no semiprime is closer to 2^2.
a(3) = 1 because 2^3 + 1 = 9 = 3^2 = A001358(3), no semiprime is closer to 2^3.
a(4) = -1 because 2^4 - 1 = 15 = 3 * 5 and no semiprime is closer.
a(5) = 1 because 2^5 + 1 = 33 = 3 * 11 and no semiprime is closer to 2^5.
a(6) = 1 because 2^6 + 1 = 65 = 5 * 13 and no semiprime is closer to 2^6.
a(7) = 1 because 2^7 + 1 = 129 = 3 * 43 and no semiprime is closer to 2^7.
a(8) = -2 because 2^8 - 2 = 254 = 2 * 127 and no semiprime is closer to 2^8.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Catch@Block[{p = 2^n, k = 0}, While[True, If[p > k && PrimeOmega[p - k] == 2, Throw[-k]]; If[PrimeOmega[p + k] == 2, Throw[k]]; k++]]; a /@ Range[0, 80] a /@ Range[0, 80] (* Giovanni Resta, Jun 15 2016 *)

Formula

a(n) = A117405(n) - 2^n. a(n) = Min{k such that A001358(i) + k = 2^j}.

Extensions

Corrected and extended by Giovanni Resta, Jun 15 2016

A059959 Distance of 2^n from its nearest prime neighbor and in case of a tie, choose the smaller.

Original entry on oeis.org

-1, 0, 1, 1, -1, 1, 3, 1, -1, 3, 3, -5, 3, 1, 3, -3, -1, 1, -3, 1, 3, 9, 3, -9, 3, -35, 5, -29, -3, 3, -3, 1, 5, 9, -25, 31, 5, -9, -7, 7, -15, 21, 11, -29, -7, 55, -15, -5, -21, -69, 27, -21, -21, -5, 33, -3, 5, -9, 27, 55, -33, 1, 57, 25, -13, 49, 5, -3, 23, 19, -25, -11, -15, -29, 35, -33, 15, -11, -7, -23, -13, -17, -9, 55, -3, 19
Offset: 0

Views

Author

Labos Elemer, Mar 02 2001

Keywords

Examples

			n=19, 2^19=524288, prevprime(524288)=524287, nextprime(524288)=524309, so min{21,1}=1=a(19).
		

Crossrefs

Programs

  • Maple
    with(numtheory): [seq(min(nextprime(2^i)-2^i, 2^i-prevprime(2^i)), i=2..100)];
  • Mathematica
    f[n_] := Block[{k = 0}, While[ !PrimeQ[2^n -k] && !PrimeQ[2^n +k], k++]; If[ PrimeQ[2^n -k], k, -k]]; Array[f, 70, 0] (* Robert G. Wilson v, Mar 14 2006 and modified Jan 12 2024 *)

Formula

a(n) = A000079(n) - A117387(n).

Extensions

Signs added by Robert G. Wilson v, Mar 14 2006

A117416 Semiprime nearest to 3^n. In case of a tie, choose the smaller.

Original entry on oeis.org

4, 4, 9, 26, 82, 247, 731, 2186, 6559, 19679, 59047, 177149, 531439, 1594322, 4782979, 14348905, 43046722, 129140159, 387420493, 1162261465, 3486784399, 10460353201, 31381059597, 94143178823, 282429536489, 847288609441
Offset: 0

Views

Author

Jonathan Vos Post, Mar 13 2006

Keywords

Comments

See also: A117405 Semiprime nearest to 2^n. A117387 Prime nearest to 2^n.

Examples

			a(0) = 4 because 3^0 + 3 = 4 = A001358(1) and no semiprime is closer to 3^0.
a(1) = 4 because 3^1 + 1 = 4 = A001358(1) and no semiprime is closer to 3^1.
a(2) = 9 because 3^2 + 0 = 9 = 3^2 = A001358(3), no semiprime is closer to 3^2.
a(3) = 26 because 3^3 - 1 = 26 = 2 * 13, no semiprime is closer.
a(4) = 82 because 3^4 + 1 = 82 = 2 * 41, no semiprime is closer.
a(5) = 247 because 3^5 + 4 = 247 = 13 * 19, no semiprime is closer.
		

Crossrefs

Programs

  • Mathematica
    nsp[n_]:=Module[{c=3^n,a,b,j=1,k=1},While[PrimeOmega[c-j]!=2,j++]; a=c-j;While[ PrimeOmega[ c+k]!=2,k++];b=c+k;If[(b-c)<(c-a),b,a]]; Join[ {4,4,9}, Array[nsp,30,3]] (* Harvey P. Dale, Apr 11 2015 *)

Formula

a(n) = 3^n + A117416(n). a(n) = 3^n + Min{k such that A001358(i) + k = 3^n}.

A226178 Exponents n such that 2^n - previous_prime(2^n) = next_prime(2^n) - 2^n.

Original entry on oeis.org

2, 6, 12, 76, 181, 1099, 1820, 9229
Offset: 1

Views

Author

Jean-François Alcover, May 30 2013

Keywords

Comments

The differences next_prime(2^n) - 2^n are respectively: 1, 3, 3, 15, 165, 1035, 663, 2211.
If it exists, a(9) > 10000. - Hugo Pfoertner, Feb 06 2021

Examples

			2^6 = 64, next prime = 67, previous prime = 61, 67-64 = 64-61 = 3, hence 6 is in the sequence.
		

Crossrefs

Programs

  • Mathematica
    Reap[Do[m = 2^n; p = NextPrime[m, -1]; q = NextPrime[m]; If[p + q == 2*m, Print[n]; Sow[n]], {n, 2, 10^4}]][[2, 1]]
  • PARI
    isok(n) = my(p=2^n); p-precprime(p-1) == nextprime(p+1) - p; \\ Michel Marcus, Oct 02 2019
    
  • PARI
    for(n=2,1100,my(p2=2^n,pn=nextprime(p2),pp=p2-pn+p2);if(ispseudoprime(pp),if(precprime(p2)==pp,print1(n,", ")))) \\ Hugo Pfoertner, Feb 06 2021
    
  • Python
    from itertools import count, islice
    from sympy import isprime, nextprime
    def A226178_gen(): # generator of terms
        return filter(lambda n:isprime(r:=((k:=1<A226178_list = list(islice(A226178_gen(),5)) # Chai Wah Wu, Aug 08 2022

Formula

A340707(a(n)) = 0. - Hugo Pfoertner, Feb 06 2021

Extensions

Offset 1 from Michel Marcus, Oct 02 2019
a(8) from Hugo Pfoertner, Feb 05 2021

A117429 Semiprime nearest to 5^n. In case of a tie, choose the smaller.

Original entry on oeis.org

4, 4, 25, 123, 626, 3127, 15623, 78123, 390623, 1953122, 9765627, 48828127, 244140623, 1220703121, 6103515629, 30517578127, 152587890617, 762939453119, 3814697265623, 19073486328122, 95367431640623
Offset: 0

Views

Author

Jonathan Vos Post, Mar 14 2006

Keywords

Examples

			a(0) = 4 because 5^0 + 3 = 4 = A001358(1) and no semiprime is closer to 5^0.
a(1) = 4 because 5^1 - 1 = 4 = A001358(1) and no semiprime is closer to 5^1.
a(2) = 25 because 5^2 + 0 = 25 = A001358(9), no semiprime is closer to 5^2.
a(3) = 123 because 5^3 - 2 = 123 = 3 * 41 = A001358(42), no semiprime is closer.
a(4) = 626 because 5^4 + 1 = 626 = 2 * 313, no semiprime is closer.
a(5) = 3127 because 5^5 + 2 = 3127 = 53 * 59, no semiprime is closer.
a(6) = 15623 because 5^6 - 2 = 15623 = 17 * 919, no semiprime is closer.
a(7) = 78123 because 5^7 - 2 = 78123 = 3 * 26041, no semiprime is closer.
a(8) = 390623 because 5^8 - 2 = 390623 = 73 * 5351, no semiprime is closer.
a(9) = 1953122 because 5^9 - 3 = 1953122 = 2 * 976561, no semiprime is closer.
a(10) = 9765627 because 5^10 + 2 = 9765627 = 3 * 3255209, no semiprime closer.
		

Crossrefs

Cf. A117416 = Semiprime nearest to 3^n, A117405 = Semiprime nearest to 2^n, A117387 = Prime nearest to 2^n.

Programs

  • Maple
    nsp:= proc(n) uses numtheory; local k;
      if bigomega(n)=2 then return n fi;
      for k from 1 do
        if n-k > 0 and bigomega(n-k)=2 then return n-k fi;
        if bigomega(n+k)=2 then return n+k fi
      od
    end proc:
    seq(nsp(5^k),k=0..30); # Robert Israel, May 03 2018
  • Mathematica
    sp1[n_]:=Module[{k=0},While[PrimeOmega[n-k]!=2,k++];n-k]; sp2[n_]:= Module[ {k=1}, While[ PrimeOmega[n+k]!=2,k++];n+k]; Join[{4},Nearest[ {sp1[#], sp2[#]}, #][[1]]&/@(5^Range[20])] (* Harvey P. Dale, Aug 11 2019 *)

Formula

a(n) = 5^n + A117430(n).

Extensions

Edited by Robert Israel, May 03 2018

A117430 Integer k such that 5^n + k = A117429(n).

Original entry on oeis.org

3, -1, 0, -2, 1, 2, -2, -2, -2, -3, 2, 2, -2, -4, 4, 2, -8, -6, -2, -3, -2, -2, 4, 2, -6, -2, 4, 2, -3, 17, 9, -4, -8, -6, 12, 14, -2, -6, -8, -2, -6, 24, -2, 14, -6, -4, -18, -6, -3, -6, 16, -10, 16, -12, 12, -2, 16, 6, 16, -12, -2, -6, 12, -12, -8, -19, -6, 6, 24, -16, 4, 2, 16, -4, -8, -4, 16
Offset: 0

Views

Author

Jonathan Vos Post, Mar 14 2006

Keywords

Comments

(+/-) distance from 5^n to the nearest semiprime.
a(0)=3 and a(1)=-1 are the only terms == 3 (mod 4), as 5^n + 3 is divisible by 4. - Robert Israel, May 03 2018

Examples

			a(0) = 3 because 5^0 + 3 = 4 = A001358(1) and no semiprime is closer to 5^0.
a(1) = -1 because 5^1 - 1 = 4 = A001358(1) and no semiprime is closer to 5^1.
a(2) = 0 because 5^2 + 0 = 25 = A001358(9), no semiprime is closer to 5^2 [this is the only 0 element].
a(3) = -2 because 5^3 - 2 = 123 = 3 * 41 = A001358(42), no semiprime is closer.
a(4) = 1 because 5^4 + 1 = 626 = 2 * 313, no semiprime is closer.
a(5) = 2 because 5^5 + 2 = 3127 = 53 * 59, no semiprime is closer.
		

Crossrefs

Programs

  • Maple
    nsp:= proc(n) uses numtheory; local k;
      if bigomega(n)=2 then return n fi;
      for k from 1 do
        if n-k > 0 and bigomega(n-k)=2 then return n-k fi;
        if bigomega(n+k)=2 then return n+k fi
      od
    end proc:
    seq(nsp(5^n)-5^n, n=0..30); # Robert Israel, May 03 2018
  • Mathematica
    nsp[n_] := Module[{k}, If[PrimeOmega[n] == 2, Return[n]]; For[k = 1, True, k++, If[n-k > 0 && PrimeOmega[n-k] == 2, Return[n-k]]; If[PrimeOmega[n+k] == 2, Return[n+k]]]];
    a[n_] := a[n] = nsp[5^n] - 5^n;
    Table[Print[n, " ", a[n]]; a[n], {n, 0, 76}] (* Jean-François Alcover, Jul 23 2020, after Maple *)

Formula

a(n) = Integer k such that 5^n + k = A117429(n). a(n) = A117429(n) - 5^n. a(n) = Min{k such that A001358(i) + k = 5^n}.

Extensions

More terms from Robert Israel, May 03 2018

A356434 Prime nearest to 2^n. In case of a tie, choose the larger.

Original entry on oeis.org

2, 2, 5, 7, 17, 31, 67, 127, 257, 509, 1021, 2053, 4099, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573, 2097143, 4194301, 8388617, 16777213, 33554467, 67108859, 134217757, 268435459, 536870909, 1073741827, 2147483647, 4294967291, 8589934583
Offset: 0

Views

Author

Peter Munn, Aug 07 2022

Keywords

Crossrefs

A117387 differs by preferring the smaller prime in the case of a tie, which occurs when n is in A226178.

Programs

  • Mathematica
    Join[{2,2},Table[Max[Nearest[{NextPrime[2^n,-1],NextPrime[2^n]},2^n]],{n,2,40}]] (* Harvey P. Dale, Feb 19 2023 *)
  • Python
    from sympy import prevprime, nextprime
    def A356434(n): return (r if (m:=nextprime(k:=1< (k<<1)-(r:=prevprime(k)) else m) if n>1 else 2 # Chai Wah Wu, Aug 08 2022

Formula

a(0) = 2; for n >= 1, if A014210(n) + A014234(n) > 2^(n+1) then a(n) = A014234(n), otherwise a(n) = A014210(n).

A117417 Integer k such that 3^n + k = A117416(n).

Original entry on oeis.org

3, 1, 0, -1, 1, 4, 2, -1, -2, -4, -2, 2, -2, -1, 10, -2, 1, -4, 4, -2, -2, -2, -12, -4, 8, -2, -7, 2, -2, 8, 14, -5, 1, -4, -8, -4, 16, 6, -6, -2, 2, -8, -2, 12, -2, -5, -8, 10, -2, 4, -10, 40, 8, -10, 4, -2, -34, -2, 4, -20, -2
Offset: 0

Views

Author

Jonathan Vos Post, Mar 13 2006

Keywords

Comments

Distance from 3^n to the nearest semiprime. If there are two semiprimes at the same distance, take the negative k-value.
See also: A117405 Semiprime nearest to 2^n. A117387 Prime nearest to 2^n.

Examples

			a(0) = 3 because 3^0 + 3 = 4 = A001358(1) and no semiprime is closer to 3^0.
a(1) = 1 because 3^1 + 1 = 4 = A001358(1) and no semiprime is closer to 3^1.
a(2) = 0 because 3^2 + 0 = 9 = 3^2 = A001358(3), no semiprime is closer to 3^2 [this is the only 0 element].
a(3) = -1 because 3^3 - 1 = 26 = 2 * 13, no semiprime is closer.
a(4) = 1 because 3^4 + 1 = 82 = 2 * 41, no semiprime is closer.
a(5) = 4 because 3^5 + 4 = 247 = 13 * 19, no semiprime is closer.
		

Crossrefs

Formula

a(n) = Integer k such that 3^n + k = A117416(n). a(n) = A117416(n) - 3^n. a(n) = Min{k such that A001358(i) + k = 3^n}.
Showing 1-9 of 9 results.