OFFSET
1,3
COMMENTS
If k is in this sequence then all permutations of (the digits of) k are in this sequence.
LINKS
Nathaniel Johnston, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Digital Root
Eric Weisstein's World of Mathematics, Multiplicative Digital Root
Wikipedia, Digital root
Wikipedia, Multiplicative digital root
MAPLE
A007954 := proc(n) return mul(d, d=convert(n, base, 10)): end: A031347 := proc(n) local m: m:=n: while(length(m)>1)do m:=A007954(m): od: return m: end: A064702 := proc(n) option remember: local k: if(n=1)then return 1:fi: for k from procname(n-1)+1 do if(A031347(k)-1 = (k-1) mod 9)then return k: fi: od: end: seq(A064702(n), n=1..56); # Nathaniel Johnston, May 04 2011
MATHEMATICA
okQ[n_]:=NestWhile[Times@@IntegerDigits[#]&, n, #>9&]== NestWhile[ Total[ IntegerDigits[ #]]&, n, #>9&]; Select[Range[1000], okQ] (* Harvey P. Dale, Apr 20 2011 *)
PROG
(Haskell)
a064702 n = a064702_list !! (n-1)
a064702_list = filter (\x -> a010888 x == a031347 x) [1..]
-- Reinhard Zumkeller, Jul 10 2013
(PARI) is(n) = my(cn = n); while(cn > 9, d = digits(cn); cn = prod(i = 1, #d, d[i])); cn - 1 == (n-1)%9 \\ David A. Corneth, Aug 23 2018
(Python)
from math import prod
def A010888(n):
while n > 9: n = sum(map(int, str(n)))
return n
def A031347(n):
while n > 9: n = prod(map(int, str(n)))
return n
print([k for k in range(840) if ok(k)]) # Michael S. Branicky, Sep 17 2022
CROSSREFS
KEYWORD
easy,nice,nonn,base
AUTHOR
Santi Spadaro, Oct 12 2001
EXTENSIONS
Definition rephrased by Reinhard Zumkeller, Jul 10 2013
Initial 0 added by Halfdan Skjerning, Aug 21 2018
STATUS
approved