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

A039634 Fixed point of "n -> n/2 or (n-1)/2 until result is prime".

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

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

Crossrefs

Programs

  • Haskell
    a039634 1 = 1
    a039634 n = until ((== 1) . a010051) (flip div 2) n
    -- Reinhard Zumkeller, Nov 17 2013
    
  • Mathematica
    ner[ n_Integer ] := FixedPoint[ If[ EvenQ[ # ]&&#>2, #/2, If[ PrimeQ[ # ]||(#=== 1), #, (#-1)/2 ] ]&, n, 20 ]
  • 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

Extensions

Offset corrected by Reinhard Zumkeller, Nov 17 2013

A039641 Fixed point of "k -> k/2 or (k+1)/2 until result is prime", starting with prime(n)+1.

Original entry on oeis.org

3, 2, 3, 2, 3, 7, 5, 5, 3, 2, 2, 19, 11, 11, 3, 7, 2, 31, 17, 5, 37, 5, 11, 23, 13, 13, 13, 7, 7, 29, 2, 17, 5, 5, 19, 19, 79, 41, 11, 11, 23, 23, 3, 97, 13, 13, 53, 7, 29, 29, 59, 2, 61, 2, 17, 17, 17, 17, 139, 71, 71, 37, 5, 5, 157, 5, 83, 43, 11, 11, 89, 23, 23, 47, 3, 3, 13
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Haskell
    a039641 = until ((== 1) . a010051) (flip div 2 . (+ 1)) . (+ 1) . a000040
    -- Reinhard Zumkeller, Nov 17 2013
  • Mathematica
    (* See A039635. *)
    Table[NestWhile[If[EvenQ[#],#/2,(#+1)/2]&,n+1,!PrimeQ[#]&],{n,Prime[ Range[ 80]]}] (* Harvey P. Dale, May 12 2014 *)

Extensions

Offset corrected by Reinhard Zumkeller, Nov 17 2013

A039643 Number of steps to fixed point of "k -> k/2 or (k-1)/2 until result is prime", starting with prime(n)+1.

Original entry on oeis.org

1, 2, 2, 3, 3, 2, 4, 3, 4, 3, 5, 2, 4, 3, 5, 3, 4, 2, 3, 6, 2, 5, 5, 4, 6, 6, 4, 4, 4, 5, 7, 7, 4, 4, 3, 4, 2, 3, 6, 3, 5, 5, 7, 2, 7, 7, 3, 6, 6, 6, 4, 6, 6, 4, 8, 8, 3, 5, 2, 5, 3, 3, 5, 5, 2, 3, 3, 7, 4, 4, 6, 6, 5, 5, 4, 8, 3, 2, 8, 8, 6, 2, 6, 6, 6, 6, 7, 2, 7, 5, 5, 7, 4, 4, 5, 5, 3, 9, 3, 2, 3, 3
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Haskell
    a039643 n = snd $ until ((== 1) . a010051 . fst)
                      (\(x, i) -> (x `div` 2 , i + 1)) (a000040 n + 1, 1)
    -- Reinhard Zumkeller, Nov 17 2013
  • Mathematica
    (* See A039636. *)

Extensions

Offset corrected by Reinhard Zumkeller, Nov 17 2013
Showing 1-3 of 3 results.