A237427 a(0)=0, a(1)=1; thereafter, if n is k-th ludic number [i.e., n = A003309(k)], a(n) = 1 + (2*a(k-1)); otherwise, when n is k-th nonludic number [i.e., n = A192607(k)], a(n) = 2*a(k).
0, 1, 3, 7, 2, 15, 6, 5, 14, 4, 30, 31, 12, 13, 10, 28, 8, 11, 60, 62, 24, 26, 20, 29, 56, 9, 16, 22, 120, 61, 124, 48, 52, 40, 58, 112, 18, 63, 32, 44, 240, 25, 122, 27, 248, 96, 104, 21, 80, 116, 224, 36, 126, 57, 64, 88, 480, 50, 244, 54, 496, 17, 192, 208, 42
Offset: 0
Examples
For n=2, with 2 being the second ludic number (= A003309(2)), the value is computed as 1+(2*a(2-1)) = 1+2*a(1) = 1+2 = 3, thus a(2)=3. For n=3, with 3 being the third ludic number (= A003309(3)), the value is computed as 1+(2*a(3-1)) = 1+2*a(2) = 1+2*3 = 7, thus a(3)=7. For n=4, with 4 being the first nonludic number (= A192607(1)), the value is computed as 2*a(1) = 2 = a(4). For n=5, with 5 being the fourth ludic number (= A003309(4)), the value is computed as 1+(2*a(4-1)) = 1+2*a(3) = 1+2*7 = 15 = a(5). For n=9, with 9 being the fourth nonludic number (= A192607(4)), the value is computed as 2*a(4) = 2*2 = 4 = a(9).
Links
Crossrefs
Programs
-
Haskell
import Data.List (elemIndex); import Data.Maybe (fromJust) a237427 = (+ 1) . fromJust . (`elemIndex` a237126_list)
-
Mathematica
nmax = 100; T = Range[2, nmax+7]; L = {1}; While[Length[T] > 0, With[{k = First[T]}, AppendTo[L, k]; T = Drop[T, {1, -1, k}]]]; nonL = Complement[Range[Last[L]], L]; a[n_] := a[n] = Module[{k}, Which[ n < 2, n, IntegerQ[k = FirstPosition[L, n][[1]]], 1 + 2 a[k-1], IntegerQ[k = FirstPosition[nonL, n][[1]]], 2 a[k], True , Print[" error: n = ", n]]]; Table[a[n], {n, 0, nmax}] (* Jean-François Alcover, Oct 10 2021, after Ray Chandler in A003309 *)
-
Scheme
;; With Antti Karttunen's IntSeq-library for memoizing definec-macro. (definec (A237427 n) (cond ((< n 2) n) ((= 1 (A192490 n)) (+ 1 (* 2 (A237427 (- (A192512 n) 1))))) (else (* 2 (A237427 (A236863 n)))))) ;; Antti Karttunen, Feb 07 2014
Comments