OFFSET
0,3
COMMENTS
a(n) = (Weight of quaternary expansion of n) + (length of quaternary expansion of n) - 1.
LINKS
Peter Kagey, Table of n, a(n) for n = 0..10000
FORMULA
EXAMPLE
For a(308) = 9, the nine steps are: 308 => 77 => 76 => 19 => 18 => 17 => 16 => 4 => 1 => 0.
MAPLE
a:= n-> (l-> nops(l)+add(i, i=l)-1)(convert(n, base, 4)):
seq(a(n), n=0..105); # Alois P. Heinz, Jul 16 2015
PROG
(Ruby) def a(n); n.to_s(4).length + n.to_s(4).split('').map(&:to_i).reduce(:+) - 1 end
(PARI) a(n)=sumdigits(n, 4)+#digits(n, 4)-1 \\ Charles R Greathouse IV, Jul 16 2015
(Haskell)
c i = if i `mod` 4 == 0 then i `div` 4 else i - 1
b 0 foldCount = foldCount
b sheetCount foldCount = b (c sheetCount) (foldCount + 1)
a260112 n = b n 0 -- Peter Kagey, Sep 02 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Peter Kagey, Jul 16 2015
STATUS
approved