[go: up one dir, main page]

login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A104895 a(0)=0; thereafter a(2n) = -2*a(n), a(2n+1) = 2*a(n) - 1. 4

%I #32 Jun 15 2021 01:30:46

%S 0,-1,-2,1,-4,3,2,-3,-8,7,6,-7,4,-5,-6,5,-16,15,14,-15,12,-13,-14,13,

%T 8,-9,-10,9,-12,11,10,-11,-32,31,30,-31,28,-29,-30,29,24,-25,-26,25,

%U -28,27,26,-27,16,-17,-18,17,-20,19,18,-19,-24,23,22,-23,20,-21,-22,21,-64,63,62,-63,60,-61,-62,61,56,-57,-58,57,-60,59

%N a(0)=0; thereafter a(2n) = -2*a(n), a(2n+1) = 2*a(n) - 1.

%C Columns of table in A104894 written in base 10.

%C Conjecture: the positions where 0, 1, 2, 3, ... appear are given by A048724; the positions where -1, -2, -3, ... appear are given by A065621.

%H N. J. A. Sloane, <a href="/A104895/b104895.txt">Table of n, a(n) for n = 0..20000</a>

%F a(0) = 0 and for k>=0, 0<= j <2^k, a(2^k + j) = a(j) + 2^k if a(j)<0, a(2^k + j) = a(j) - 2^k if a(j)>=0.

%F Sum_{0 <= n <= 2^k - 1} a(n) = - 2^(k-1).

%F Sum_{0 <= n <= 2^k - 1} |a(n)| = 4^(k-1).

%F a(n) = -A065620(n). - _M. F. Hasler_, Apr 16 2018

%p f:=proc(n) option remember; if n=0 then RETURN(0); fi; if n mod 2 = 0 then RETURN(2*f(n/2)); else RETURN(-2*f((n-1)/2)-1); fi; end;

%t a[0] = 0;

%t a[n_]:= a[n]= If[EvenQ[n], 2 a[n/2], -2 a[(n-1)/2] - 1];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Aug 03 2018 *)

%o (Haskell)

%o import Data.List (transpose)

%o a104895 n = a104895_list !! n

%o a104895_list = 0 : concat (transpose [map (negate . (+ 1)) zs, tail zs])

%o where zs = map (* 2) a104895_list

%o -- _Reinhard Zumkeller_, Mar 26 2014

%o (Sage)

%o def a(n):

%o if (n==0): return 0

%o elif (mod(n,2)==0): return 2*a(n/2)

%o else: return -2*a((n-1)/2) - 1

%o [a(n) for n in (0..100)] # _G. C. Greubel_, Jun 15 2021

%Y Cf. A048724, A065621, A104894.

%Y The negative of entry A065620.

%K sign,look,nice

%O 0,3

%A _Philippe Deléham_, Apr 24 2005

%E Corrected by _N. J. A. Sloane_, Nov 05 2005

%E Edited by _N. J. A. Sloane_, Apr 25 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 29 06:09 EDT 2024. Contains 375510 sequences. (Running on oeis4.)