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 A091938 #13 Apr 09 2020 00:56:02 %S A091938 3,7,11,31,47,127,191,383,991,2039,3583,8191,15359,20479,63487,131071, %T A091938 245759,524287,786431,1966079,4128767,7323647,14680063,33546239, %U A091938 67108351,100646911,260046847,536739839,1073479679,2147483647 %N A091938 Smallest prime between 2^n and 2^(n+1), having a maximal number of 1's in binary representation. %C A091938 A091937(n) = A000120(a(n)). %H A091938 Chai Wah Wu, <a href="/A091938/b091938.txt">Table of n, a(n) for n = 1..1000</a> %t A091938 NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; p = 2; Do[c = 0; While[p < 2^n, b = Count[ IntegerDigits[p, 2], 1]; If[c < b, c = b; q = p]; p = NextPrim[p]]; Print[q], {n, 1, 30}] (* _Robert G. Wilson v_, Feb 21 2004 *) %t A091938 b[n_] := Min[ Select[ FromDigits[ #, 2] & /@ (Join[{1}, #, {1}] & /@ Permutations[ Join[{0}, Table[1, {n - 2}]]]), PrimeQ[ # ] &]]; c[n_] := Min[ Select[ FromDigits[ #, 2] & /@ (Join[{1}, #, {1}] & /@ Permutations[ Join[{0, 0}, Table[1, {n - 3}]]]), PrimeQ[ # ] &]]; f[n_] := If[ PrimeQ[2^(n + 1) - 1], 2^(n + 1) - 1, If[ PrimeQ[ b[n]], b[n], c[n]]]; Table[ f[n], {n, 30}] (* _Robert G. Wilson v_ *) %o A091938 (Python) %o A091938 from sympy import isprime %o A091938 from sympy.utilities.iterables import multiset_permutations %o A091938 def A091938(n): %o A091938 for i in range(n,-1,-1): %o A091938 q = 2**n %o A091938 for d in multiset_permutations('0'*(n-i)+'1'*i): %o A091938 p = q+int(''.join(d),2) %o A091938 if isprime(p): %o A091938 return p # _Chai Wah Wu_, Apr 08 2020 %Y A091938 Cf. A091936, A000668. %K A091938 nonn %O A091938 1,1 %A A091938 _Reinhard Zumkeller_, Feb 14 2004 %E A091938 More terms from _Robert G. Wilson v_, Feb 20 2004