|
|
A330355
|
|
Starting from n: as long as the decimal representation contains a positive multiple of 3, divide the largest and leftmost such substring by 3; a(n) corresponds to the final value.
|
|
1
|
|
|
0, 1, 2, 1, 4, 5, 2, 7, 8, 1, 10, 11, 4, 11, 14, 5, 4, 17, 2, 11, 20, 7, 22, 7, 8, 25, 22, 1, 28, 7, 10, 11, 4, 11, 14, 5, 4, 17, 2, 11, 40, 41, 14, 41, 44, 5, 14, 47, 4, 41, 50, 17, 52, 17, 2, 55, 52, 11, 58, 17, 20, 7, 22, 7, 8, 25, 22, 1, 28, 7, 70, 71, 8
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
This sequence is a variant of A329424.
|
|
LINKS
|
|
|
FORMULA
|
a(n) <= n with equality iff n = 0 or n belongs to A325112.
a(3^k) = 1 for any k >= 0.
|
|
EXAMPLE
|
For n = 193:
- 193 gives 1 followed by 93/3 = 131,
- 131 gives 1 followed by 3/3 followed by 1 = 111,
- 111 gives 111/3 = 37,
- 37 gives 3/3 followed by 7 = 17,
- neither 1, 7 nor 17 are divisible by 3, so a(193) = 17.
|
|
MAPLE
|
f:= proc(n) option remember; local L, m, i, d, np1, j, s;
L:= convert(n, base, 10);
m:= nops(L);
for d from m to 1 by -1 do
for i from 1 to m-d+1 do
s:= convert(L[i..i+d-1], `+`);
if s > 0 and s mod 3 = 0 then
np1:= add(L[j]*10^(j-1), j=1..i-1)+1/3*add(L[j]*10^(j-1), j=i..i+d-1);
return procname(np1 + 10^(2+ilog10(np1)-(i+d))*add(L[j]*10^(j-1), j=i+d..m));
fi
od
od;
n
end proc:
|
|
PROG
|
(PARI) See Links section.
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|