A145819 Union of A145812 and A145818 with double repetition of 1, so that a(1)=1, a(2)=1.
1, 1, 3, 5, 9, 11, 17, 21, 33, 35, 41, 43, 65, 69, 81, 85, 129, 131, 137, 139, 161, 163, 169, 171, 257, 261, 273, 277, 321, 325, 337, 341
Offset: 1
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
a[n_] := 2 * FromDigits[IntegerDigits[2*n-2, 2], 4] + 1; Array[a, 50] (* Amiram Eldar, Dec 16 2018 *)
a145812(n) = 2*fromdigits(binary(n-1), 4) + 1; a(n) = a145812(2*n-1); \\ Michel Marcus, Dec 13 2018
G.f.: x + 4*x^2 + 5*x^3 + 16*x^4 + 17*x^5 + 20*x^6 + 21*x^7 + 64*x^8 + ... If n=27, then b_0=1, b_1=1, b_2=0, b_3=1, b_4=1. Therefore a(27) = 4^4 + 4^3 + 4 + 1 = 325; k = b_0 + b_2*2 + b_4*2^2 = 5, l = b_1 + b_3*2 = 3, such that a(5)=17, a(3)=5 and 27 = 17 + 2*5. - _Vladimir Shevelev_, Nov 10 2008
uint32_t a_next(uint32_t a_n) { return (a_n + 0xaaaaaaab) & 0x55555555; } /* Falk Hüffner, Jan 24 2022 */
a000695 n = if n == 0 then 0 else 4 * a000695 n' + b where (n',b) = divMod n 2 -- Reinhard Zumkeller, Feb 21 2014, Dec 03 2011
function a(n) m, r, b = n, 0, 1 while m > 0 m, q = divrem(m, 2) r += b * q b *= 4 end r end; [a(n) for n in 0:51] |> println # Peter Luschny, Jan 03 2021
m:=60; R:=PowerSeriesRing(Integers(), m); [0] cat Coefficients(R!( (&+[4^k*x^(2^k)/(1+x^(2^k)): k in [0..20]])/(1-x) )); // G. C. Greubel, Dec 06 2018
a:= proc(n) local m, r, b; m, r, b:= n, 0, 1; while m>0 do r:= r+b*irem(m, 2, 'm'); b:= b*4 od; r end: seq(a(n), n=0..100); # Alois P. Heinz, Mar 16 2013
Table[FromDigits[Riffle[IntegerDigits[n, 2], 0], 2], {n, 0, 51}] (* Jacob A. Siehler, Jun 30 2010 *) Table[FromDigits[IntegerDigits[n, 2], 4], {n, 0, 51}] (* IWABUCHI Yu(u)ki, Apr 06 2013 *) Union@ Flatten@ NestList[ Join[ 4#, 4# + 1] &, {0}, 6] (* Robert G. Wilson v, Aug 30 2014 *) Select[ Range[0, 1320], Total@ IntegerDigits[#, 2] == Total@ IntegerDigits[#, 4] &] (* Robert G. Wilson v, Oct 24 2014 *) Union[FromDigits[#,4]&/@Flatten[Table[Tuples[{0,1},n],{n,6}],1]] (* Harvey P. Dale, Oct 03 2015 *) a[ n_] := Which[n < 1, 0, EvenQ[n], a[n/2] 4, True, a[n - 1] + 1]; (* Michael Somos, Nov 30 2016 *)
a(n)=n=binary(n);sum(i=1,#n,n[i]*4^(#n-i)) \\ Charles R Greathouse IV, Mar 04 2013
{a(n) = if( n<1, 0, n%2, a(n-1) + 1, a(n/2) * 4)}; /* Michael Somos, Nov 30 2016 */
A000695(n)=fromdigits(binary(n),4) \\ M. F. Hasler, Oct 16 2018
def a(n): n = bin(n)[2:] x = len(n) return sum(int(n[i]) * 4**(x - 1 - i) for i in range(x)) [a(n) for n in range(101)] # Indranil Ghosh, Jun 25 2017
def a(): x = 0 while True: yield x y = ~(x << 1) x = (x - y) & y # Falk Hüffner, Dec 21 2021
from itertools import count, islice def A000695_gen(): # generator of terms yield (a:=0) for n in count(1): yield (a := a+((1<<((~n & n-1).bit_length()<<1)+1)+1)//3) A000695_list = list(islice(A000695_gen(),30)) # Chai Wah Wu, Feb 22 2023
def A000695(n): return int(bin(n)[2:],4) # Chai Wah Wu, Aug 21 2023
s=(sum(4^k*x^(2^k)/(1+x^(2^k)) for k in range(10))/(1-x)).series(x, 60); s.coefficients(x, sparse=False) # G. C. Greubel, Dec 06 2018
aQ[n_] := OddQ[n] && Module[{d = Reverse[IntegerDigits[n, 2]]}, Length[d] < 2 || Max[d[[2;; -1;; 2]]] == 0]; Select[Range[4500], aQ] (* Amiram Eldar, Dec 15 2018 *)
isok(n) = {if (n % 2, my(rb = Vecrev(binary(n)), brb = vector(#rb\2, k, rb[2*k])); (#brb == 0) || vecmax(brb) == 0, 0);} \\ Michel Marcus, Dec 15 2018
If n=4, 2n+1 = 9 = 1 + 0*2 + 0*2^2 + 1*2^3, so a(4) = 1 + 0*2 + 1*2^3 = 9.
a088442 = (+ 1) . a004514 -- Reinhard Zumkeller, Sep 26 2015
function A063694(n) if n le 1 then return n; else return 4*A063694(Floor(n/4)) + (n mod 2); end if; return A063694; end function; A088442:= func< n | 2*A063694(n) + 1 >; [A088442(n): n in [0..100]]; // G. C. Greubel, Dec 05 2022
a:=proc(n) local b: b:=convert(2*n+1,base,2): 1+sum(b[2*j]*2^(2*j-1),j=1..nops(b)/2) end: seq(a(n),n=0..100); with(Bits): seq(And(2*n+1, convert("aaaaaa", decimal, hex)) + 1, n=0..127); # Georg Fischer, Dec 03 2022
A004514[n_]:= A004514[n]= If[n==0, 0, 2*(n-A004514[Floor[n/2]])]; A088442[n_] := A004514[n] +1; Table[A088442[n], {n,0,100}] (* G. C. Greubel, Dec 05 2022 *)
def A088442(n): return ((n&((1<<(m:=n.bit_length())+(m&1))-1)//3)<<1)+1 # Chai Wah Wu, Jan 30 2023
def A063694(n): if (n<2): return n else: return 4*A063694(floor(n/4)) + (n%2) def A088442(n): return 2*A063694(n) + 1 [A088442(n) for n in range(101)] # G. C. Greubel, Dec 05 2022
a(2)=11, since people are eliminated in the order 2, 4, 6, 8, 10, 12, 9, 5, 1, 7, 3, leaving 11 as the survivor.
def A090569(n): return (n-1&((1<<(m:=(n-1).bit_length())+(m&1^1))-1)//3)+1 # Chai Wah Wu, Jan 30 2023
If m=46, then we have 46=1*3^0+2*3^2+1*3^3, thus a(l)=1+1*3^3=28 and the required decomposition is: 46=28+3*4, such that a(s)=4. We see that l=4, s=2, i.e. "index coordinates" of 46 are (4, 2). Thus we have a one-to-one map of integers m==1(mod 3), m>=4, to the positive lattice points on the plane.
isok(n) = {my(d=Vecrev(digits(n, 3)), k=3); while (k <= #d, if (d[k], return (0)); k += 2;); d[1] == 1;} \\ Michel Marcus, Dec 09 2018
fQ[n_] := Module[{d = Reverse[IntegerDigits[n, 3]], k = 3, ans = True}, While[k <= Length[d], If[d[[k]] > 0, ans = False]; k += 2]; ans && d[[1]] == 1]; aQ[n_] := Mod[n + 1, 3] == 0 && fQ[(n + 1)/3]; Select[Range[10000], aQ] (* Amiram Eldar, Dec 09 2018 *)
isa(n) = {my(d=Vecrev(digits(n, 3)), k=3); while (k <= #d, if (d[k], return (0)); k += 2;); d[1] == 1;} \\ A146085 isok(n) = !((n+1) % 3) && isa((n+1)/3); \\ Michel Marcus, Dec 09 2018
A000695[n_]:= FromDigits[IntegerDigits[n,2], 4]; Table[(3+(-1)^n)*A000695[Floor[(2*n-2-(-1)^n)/4]] +4+(-1)^n , {n, 202}]//DeleteDuplicates//Sort (* G. C. Greubel, May 22 2023 *)
a147568(n) = 2*fromdigits(binary(n), 4) + 3; lista(nn) = {my(v = vector(2*nn+2), ind = 0); for (n=0, nn, my(x = a147568(n)); v[ind++] = x; v[ind++] = 2*x - 1); vecsort(v,,8);} \\ Michel Marcus, Dec 18 2018
Comments