A330634 The number of iterations of A330633, the concatenation of the product of adjacent digits, for starting value n before reaching 0, or -1 if this never happens.
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 1, 2, 2, 3, 3, 2, 3, 4, 3, 4, 1, 2, 2, 3, 2, 3, 2, 4, 2, 3, 1, 2, 3, 3, 3, 2, 4, 3, 4, 3, 1, 2, 3, 3, 4, 4, 3, 5, 3, 4, 1, 2, 3, 3, 3, 2, 4, 3, 4, 4, 1, 2, 3, 4, 4, 3, 3, 4, 4, 3, 1, 1
Offset: 0
Examples
a(1) = 1 as A330633(1) = 0, taking 1 iteration to reach 0. a(11) = 2 as A330633(11) = 1 and A330633(1) = 0, taking 2 iterations to reach 0. a(77) = 5 as A330633(77) = 49, A330633(49) = 36, A330633(36) = 18, A330633(18) = 8, A330633(8) = 0, taking 5 iterations to reach 0. a(166) = -1 as A330633(166) = 636, A330633(636) = 1818, A330633(1818) = 888, which is guaranteed to diverge.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
Programs
-
Maple
f:= proc(n) local L,i; L:= convert(n,base,10); if ormap(t -> L[t..t+2] = [8,8,8], [$1..nops(L)-2]) then return -1 fi; parse(cat(seq(L[i]*L[i+1],i=nops(L)-1 .. 1, -1))) end proc; for i from 1 to 9 do f(i):= 0 od: g:= proc(i) option remember; local v; v:= f(i); if v = -1 then -1 else v:= procname(v); if v = -1 then -1 else 1 + v fi fi; end proc: g(0):= 0: map(g, [$0..200]); # Robert Israel, Jun 30 2024
-
Mathematica
Array[If[#[[-1]] == 888, -1, Length@ # - 1] &@ NestWhileList[If[Or[# == 0, IntegerLength@ # == 1], 0, FromDigits[Join @@ IntegerDigits[Times @@ # & /@ Partition[IntegerDigits@ #, 2, 1]]]] &, #, And[# > 0, # != 888] &] &, 102, 0] (* Michael De Vlieger, Dec 23 2019 *)
Comments