login
A126759
a(0) = 1; a(2n) = a(n); a(3n) = a(n); otherwise write n = 6i+j, where j = 1 or 5 and set a(n) = 2i+2 if j = 1, otherwise a(n) = 2i+3.
4
1, 2, 2, 2, 2, 3, 2, 4, 2, 2, 3, 5, 2, 6, 4, 3, 2, 7, 2, 8, 3, 4, 5, 9, 2, 10, 6, 2, 4, 11, 3, 12, 2, 5, 7, 13, 2, 14, 8, 6, 3, 15, 4, 16, 5, 3, 9, 17, 2, 18, 10, 7, 6, 19, 2, 20, 4, 8, 11, 21, 3, 22, 12, 4, 2, 23, 5, 24, 7, 9, 13, 25, 2, 26, 14, 10, 8, 27, 6, 28, 3, 2, 15, 29, 4, 30, 16, 11, 5, 31, 3
OFFSET
0,2
COMMENTS
Invented by Miles Okazaki, who said: I was trying to write a composition that has the same melody going at several different speeds. If this sequence is mapped onto musical notes and you play every other term, you get the original sequence at half speed. If you play every third term, you again get the same melody. And every 4th term, 6th term, 8th term, 12th term, etc. yields the same result. The pattern generates itself, adding two new increasing integers every six terms.
The formula in the definition encapsulates this verbal description. - N. J. A. Sloane
LINKS
FORMULA
For k > 1: a(A007310(k-1)) = k and a(m) < k for m < A007310(k-1). - Reinhard Zumkeller, Jun 16 2008
For n > 0: a(A007310(n)) = n and a(m) < n for m < A007310(n). - Reinhard Zumkeller, May 23 2013
a(0) = 1, a(2n) = a(n), a(3n) = a(n), a(6n+1) = 2n + 2, a(6n-1) = 2n + 1. [Essentially same as the original description, except the last clause expressed slightly differently.] - Antti Karttunen, Jan 28 2015
MAPLE
a:=proc(n) option remember; local i, j;
if n = 0 then RETURN(1); fi;
if n mod 2 = 0 then RETURN(a(n/2)); fi;
if n mod 3 = 0 then RETURN(a(n/3)); fi;
j := n mod 6; i := (n-j)/6;
if j = 1 then RETURN(2*i+2) else RETURN(2*i+3); fi;
end;
[seq(a(n), n=0..100)];
MATHEMATICA
a[n_] := a[n] = Module[{i, j}, If[n == 0, Return[1]]; If[Mod[n, 2] == 0, Return[a[n/2]]]; If[Mod[n, 3] == 0, Return[a[n/3]]]; j = Mod[n, 6]; i = (n-j)/6; If[j == 1, Return[2*i+2], Return[2*i+3]]]; Table[a[n], {n, 0, 90}] (* Jean-François Alcover, Feb 11 2014, after Maple *)
PROG
(Haskell)
a126759 n = a126759_list !! n
a126759_list = 1 : f 1 where
f n = (case mod n 6 of 1 -> 2 * div n 6 + 2
5 -> 2 * div n 6 + 3
3 -> a126759 $ div n 3
_ -> a126759 $ div n 2) : f (n + 1)
-- Reinhard Zumkeller, May 23 2013
(Scheme)
(definec (A126759 n) (cond ((zero? n) 1) ((even? n) (A126759 (/ n 2))) ((zero? (modulo n 3)) (A126759 (/ n 3))) ((= 1 (modulo n 6)) (+ 2 (/ (- n 1) 3))) (else (+ 1 (/ (+ n 1) 3)))))
;; Antti Karttunen, Jan 28 2015
(PARI) a(n) = if (n, if (!(n%2), a(n/2), if (!(n%3), a(n/3), my(k=n%6); if (k==1, 2*(n\6)+2, 2*(n\6)+3))), 1); \\ Michel Marcus, Aug 06 2022
CROSSREFS
One more than A126760.
Cf. A007310.
Sequence in context: A088019 A301508 A178930 * A293444 A302791 A373988
KEYWORD
nonn,nice,hear
AUTHOR
N. J. A. Sloane, based on email from Miles Okazaki (milesokazaki(AT)gmail.com), Feb 18 2007
EXTENSIONS
Typo in definition corrected by Reinhard Zumkeller, Jun 16 2008
STATUS
approved