OFFSET
0,3
COMMENTS
If n is a multiple of 7, then a(n) is also a multiple of 7. See the Bhattacharyya link. - Michel Marcus, May 11 2016
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Malay Bhattacharyya, Sanghamitra Bandyopadhyay, Ujjwal Maulik, Non-primes are recursively divisible, Acta Universitatis Apulensis, No 19/2009.
FORMULA
a(0)=0, a(n)=3*a(n/10) if n==0 (mod 10), a(n)=a(n-1)+1 otherwise. - Benoit Cloitre, Dec 21 2002
G.f.: G(x) = (1-x)^(-1) * Sum_{i>=0} 3^i*p(x^(10^i)) where p(t) = (t+2*t^2+3*t^3+4*t^4+5*t^5+6*t^6+7*t^7+8*t^8+9*t^9)/(1+t+t^2+t^3+t^4+t^5+t^6+t^7+t^8+t^9) satisfies (1-x)*G(x) = p(x) + 3*(1-x^10)*G(x^10). - Robert Israel, May 11 2016
MAPLE
a:= proc(n) option remember; n mod 10 + 3*procname(floor(n/10))
end proc:
a(0):= 0:
seq(a(i), i=0..100); # Robert Israel, May 11 2016
MATHEMATICA
a = {1}; Do[AppendTo[a, If[Mod[n, 10] == 0, 3 a[[n/10]], a[[n - 1]] + 1]], {n, 2, 76}]; {0}~Join~a (* Michael De Vlieger, May 10 2016 *)
PROG
(PARI) a(n)=if(n<1, 0, if(n%10, a(n-1)+1, 3*a(n/10)))
(PARI) a(n) = subst(Pol(digits(n)), x, 3); \\ Michel Marcus, May 10 2016
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
EXTENSIONS
More terms from Erich Friedman
STATUS
approved