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.

A037273 Number of steps to reach a prime under "replace n with concatenation of its prime factors", or -1 if no prime is ever reached.

Original entry on oeis.org

-1, 0, 0, 2, 0, 1, 0, 13, 2, 4, 0, 1, 0, 5, 4, 4, 0, 1, 0, 15, 1, 1, 0, 2, 3, 4, 4, 1, 0, 2, 0, 2, 1, 5, 3, 2, 0, 2, 1, 9, 0, 2, 0, 9, 6, 1, 0, 15
Offset: 1

Views

Author

Keywords

Comments

Starting with 49, no prime has been reached after 79 steps.
a(49) > 118, see A056938 and FactorDB link. - Michael S. Branicky, Nov 19 2020

Examples

			13 is already prime, so a(13) = 0.
Starting with 14 we get 14 = 2*7, 27 = 3*3*3, 333 = 3*3*37, 3337 = 47*71, 4771 = 13*367, 13367 is prime; so a(14) = 5.
		

Crossrefs

Programs

  • Haskell
    a037273 1 = -1
    a037273 n = length $ takeWhile ((== 0) . a010051) $
       iterate (\x -> read $ concatMap show $ a027746_row x :: Integer) n
    -- Reinhard Zumkeller, Jan 08 2013
    
  • Mathematica
    nxt[n_] := FromDigits[Flatten[IntegerDigits/@Table[#[[1]], {#[[2]]}]&/@ FactorInteger[n]]]; Table[Length[NestWhileList[nxt, n, !PrimeQ[#]&]] - 1, {n, 48}] (* Harvey P. Dale, Jan 03 2013 *)
  • PARI
    row_a027746(n, o=[1])=if(n>1, concat(apply(t->vector(t[2], i, t[1]), Vec(factor(n)~))), o) \\ after M. F. Hasler in A027746
    tonum(vec) = my(s=""); for(k=1, #vec, s=concat(s, Str(vec[k]))); eval(s)
    a(n) = if(n==1, return(-1)); my(x=n, i=0); while(1, if(ispseudoprime(x), return(i)); x=tonum(row_a027746(x)); i++) \\ Felix Fröhlich, May 17 2021
    
  • Python
    from sympy import factorint
    def a(n):
        if n < 2: return -1
        klst, f = [n], sorted(factorint(n, multiple=True))
        while len(f) > 1:
            klst.append(int("".join(map(str, f))))
            f = sorted(factorint(klst[-1], multiple=True))
        return len(klst) - 1
    print([a(n) for n in range(1, 49)]) # Michael S. Branicky, Aug 02 2021

Extensions

Edited by Charles R Greathouse IV, Apr 23 2010
a(1) = -1 by Reinhard Zumkeller, Jan 08 2013
Name edited by Felix Fröhlich, May 17 2021