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.
%I A118957 #24 Feb 23 2025 04:51:52 %S A118957 6,7,10,11,13,15,18,19,21,23,27,29,34,35,37,39,43,45,49,51,55,61,63, %T A118957 66,67,69,71,75,77,81,83,87,93,95,101,105,107,111,117,123,125,130,131, %U A118957 133,135,139,141,145,147,151,157,159,165,169,171,175,181,187,189,195,199 %N A118957 Numbers of the form 2^k + p, where p is a prime less than 2^k. %F A118957 A118952(a(n)) = 1. %p A118957 isA118957 := proc(n) %p A118957 local twok,p ; %p A118957 twok := 1 ; %p A118957 while twok < n-1 do %p A118957 p := n-twok ; %p A118957 if isprime(p) and p < twok then %p A118957 return true; %p A118957 end if; %p A118957 twok := twok*2 ; %p A118957 end do: %p A118957 return false; %p A118957 end proc: %p A118957 for n from 1 to 200 do %p A118957 if isA118957(n) then %p A118957 printf("%d,",n) ; %p A118957 end if; %p A118957 end do: # _R. J. Mathar_, Feb 27 2015 %t A118957 okQ[n_] := Module[{k, p}, For[k = Ceiling[Log[2, n]], k>1, k--, p = n-2^k; If[2 <= p < 2^k && PrimeQ[p], Return[True]]]; False]; Select[Range[200], okQ] (* _Jean-François Alcover_, Mar 11 2019 *) %o A118957 (PARI) is(n)=isprime(n-2^logint(n,2)) \\ _Charles R Greathouse IV_, Sep 01 2015; edited Jan 24 2024 %o A118957 (Python) %o A118957 from sympy import primepi %o A118957 def A118957(n): %o A118957 def bisection(f,kmin=0,kmax=1): %o A118957 while f(kmax) > kmax: kmax <<= 1 %o A118957 kmin = kmax >> 1 %o A118957 while kmax-kmin > 1: %o A118957 kmid = kmax+kmin>>1 %o A118957 if f(kmid) <= kmid: %o A118957 kmax = kmid %o A118957 else: %o A118957 kmin = kmid %o A118957 return kmax %o A118957 def f(x): return n+x-sum(primepi(min(x-(m:=1<<k),m-1)) for k in range(x.bit_length())) %o A118957 return bisection(f,n,n) # _Chai Wah Wu_, Feb 23 2025 %Y A118957 Complement of A118956; subsequence of A118955. %Y A118957 Cf. A118952, A118958, A156695. %K A118957 nonn %O A118957 1,1 %A A118957 _Reinhard Zumkeller_, May 07 2006