OFFSET
1,2
COMMENTS
n such that there exists a permutation p_1, ..., p_n of 1, ..., n such that i + p_i is a power of 8 for every i.
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..100
FORMULA
a(n) = 7*A033045(n-1).
a(2n-1) = 8*a(n), a(2n) = 8*a(n)+7.
MATHEMATICA
fQ[n_]:=Union@Join[{0, 7}, IntegerDigits[n, 8]]=={0, 7}; Select[Range[0, 300000], fQ] (* Vincenzo Librandi, May 25 2012 *)
FromDigits[#, 8]&/@Tuples[{0, 7}, 6] (* Harvey P. Dale, Aug 10 2021 *)
PROG
(Magma) [n: n in [0..250000] | Set(IntegerToSequence(n, 8)) subset {0, 7}]; // Vincenzo Librandi, May 25 2012
(Maxima) a[1]:0$ a[n]:=8*a[floor((n+1)/2)]+7*(1+(-1)^n)/2$ makelist(a[n], n, 1, 37); /* Bruno Berselli, May 25 2012 */
(PARI) a(n) = 7*fromdigits(binary(n-1), 8) \\ Rémy Sigrist, Dec 06 2018
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Ray Chandler, Aug 03 2004
STATUS
approved