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.

A171772 Number of steps needed to reach a prime when the map S(n)+M(n) is applied to n, or -1 if a prime is never reached. Here S(n) and M(N) mean the sum and the product of the digits of n in base 10.

Original entry on oeis.org

1, 0, 0, 3, 0, 2, 0, 2, 2, 2, 0, 1, 0, 3, 1, 1, 0, 1, 0, 1, 1, 3, 0, 4, 1, 2, 1, 3, 0, 1, 0, 1, 2, 1, 1, 2, 0, 2, -1, 4, 0, 4, 0, 5, 1, 2, 0, 6, -1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 0, 3, 0, 2, 2, 2, 1, 7, 0, 3, -1, 1, 0, 1, 0, -1, 1, 3, 3, 1, 0, 3
Offset: 1

Views

Author

R. J. Mathar, Oct 12 2010

Keywords

Comments

a(n)=0 if n is a prime.

Examples

			a(4)=3 because 4->8->16->13 is prime.
a(39)=-1 because 39 -> 39 ->39 ... never reaches a prime.
a(49)=-1 because 49 -> 49 ->49 ... never reaches a prime.
a(69)=-1 because 69 -> 69 ->69 ... never reaches a prime.
a(74)=-1 because 74 -> 39 ->39 ... never reaches a prime.
a(28)=3 because 28 ->26 ->20 ->2.
		

Crossrefs

A variant of A074871.

Programs

  • Maple
    f:= proc(n) local L;
      L:= convert(n,base,10);
      convert(L,`+`)+convert(L,`*`);
    end proc:
    g:= proc(n) option remember; local v,w;
         if n::prime then return 0 fi;
         v:= f(n);
         if v = n then return -1 fi;
         w:= procname(v);
         if w = -1 then -1 else w+1 fi
    end proc:
    map(g, [$1..100]); # Robert Israel, Nov 03 2019