OFFSET
0,3
LINKS
Fernando Villanueva, Table of n, a(n) for n = 0..9999
EXAMPLE
For n = 12345 the length of n is 5 (because 12345 has 5 digits) and its digital root is 6 (1+2+3+4+5=15 then 1+5=6). Then [6/5]=1 (where [x] is the integer part of x). Therefore a(12345)=0.
MATHEMATICA
Array[Floor[If[#1 == 0, 0, (#2 /. 0 -> 9)/IntegerLength[#1]]] & @@ {#, Mod[#, 9]} &, 105, 0] (* Michael De Vlieger, Nov 05 2020 *)
PROG
(Python)
#Defines digital root
def recsum(n):
nstr = str(n)
if len(nstr) == 1:
return int(nstr)
else:
nl = sum([int(j) for j in nstr])
return recsum(nl)
#Prints first 1000 terms
for i in range(1000):
print(recsum(i)//len(str(i)))
(PARI) a(n) = if (n, (n-1)%9+1, 0) \ #Str(n); \\ Michel Marcus, Nov 05 2020
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Fernando Villanueva, Oct 23 2020
STATUS
approved
