login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A039634 Fixed point of "n -> n/2 or (n-1)/2 until result is prime". 16
1, 2, 3, 2, 5, 3, 7, 2, 2, 5, 11, 3, 13, 7, 7, 2, 17, 2, 19, 5, 5, 11, 23, 3, 3, 13, 13, 7, 29, 7, 31, 2, 2, 17, 17, 2, 37, 19, 19, 5, 41, 5, 43, 11, 11, 23, 47, 3, 3, 3, 3, 13, 53, 13, 13, 7, 7, 29, 59, 7, 61, 31, 31, 2, 2, 2, 67, 17, 17, 17, 71, 2, 73, 37, 37, 19, 19, 19, 79, 5, 5 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
a(n) is the largest prime whose binary expansion is an initial substring of n's binary expansion. - Charlie Neder, Oct 27 2018
a(1) = 1 by convention. - David A. Corneth, Oct 27 2018
LINKS
MATHEMATICA
ner[ n_Integer ] := FixedPoint[ If[ EvenQ[ # ]&&#>2, #/2, If[ PrimeQ[ # ]||(#=== 1), #, (#-1)/2 ] ]&, n, 20 ]
PROG
(Haskell)
a039634 1 = 1
a039634 n = until ((== 1) . a010051) (flip div 2) n
-- Reinhard Zumkeller, Nov 17 2013
(PARI) a(n)=while(n>3 && !isprime(n), n\=2); n \\ Charles R Greathouse IV, Jun 23 2017
(Python)
from sympy import isprime
def a(n):
while n>1 and not isprime(n): n>>=1
return n
print([a(n) for n in range(1, 82)]) # Michael S. Branicky, Jul 24 2023
CROSSREFS
Sequence in context: A130088 A369033 A078834 * A078833 A210437 A109674
KEYWORD
nonn,easy,nice
AUTHOR
EXTENSIONS
Offset corrected by Reinhard Zumkeller, Nov 17 2013
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 12 02:10 EDT 2024. Contains 372431 sequences. (Running on oeis4.)