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!)
A248961 Sums of wrecker ball sequences starting with n. 5

%I #11 May 16 2019 01:32:32

%S 0,1,-2,5,-292,-241,14,-437861,-28,-1,30,313,-4472,-4223,-2,55,3252,

%T -214246256269,-70,-27,5260887648,91,-538,-193,-132,-864538549823,-22,

%U 27,140,40053,53088613819206,86166834699,86167898716,86168962733,86170026754,49,204

%N Sums of wrecker ball sequences starting with n.

%C a(n) = A248973(n, A228474(n)) = sum of row n in triangle A248939;

%C a(A000217(n)) = A000330(n).

%H Reinhard Zumkeller, <a href="/A248961/b248961.txt">Table of n, a(n) for n = 0..1000</a>

%H Gordon Hamilton, <a href="http://www.youtube.com/watch?v=mQdNaofLqVc">Wrecker Ball Sequences</a>, Video, 2013

%e a(1) = 1+0 = 1;

%e a(2) = 2+1-1-4+0 = -2;

%e a(3) = 3+2+0 = 5;

%e a(4) = 4+3+1-2+2-3-9-16-8-17-7-18-6+7+21+6-10-27-45-26-46-25-47-24+0 = -292;

%e a(5) = 5+4+2-1+3-2-8-15-7-16-6-17-5+8+22+7-9-26-44-25-45-24-46-... = -241;

%e a(6) = 6+5+3+0 = 14;

%e a(7) = 7+6+4+1-3+2-4+3-5-14-24-13-1+12-2+13+29+46+28+9-11+10-... = -437861;

%e a(8) = 8+7+5+2-2+3-3+4-4-13-23-12+0 = -28;

%e a(9) = 9+8+6+3-1+4-2+5-3-12-22-11+1+14+0 = -1.

%o (Haskell) import Data.IntSet (singleton, member, insert)

%o a248961 n = addup 1 n 0 $ singleton n where

%o addup _ 0 sum _ = sum

%o addup k x sum s = addup (k + 1) y (sum + x) (insert y s) where

%o y = x + (if (x - j) `member` s then j else -j)

%o j = k * signum x

%o (C++) #include<set>

%o long A248961(long n) { long c=0, d, S=n; for(std::set<long> A; n; A.insert(n), S += n += A.count(n - (d = n>0 ? c : -c)) ? d : -d) ++c; return S; } // _M. F. Hasler_, Mar 19 2019

%o (PARI) A248961(n,A=[n],c,S=n)={while( n+=sign(n)*if(setsearch(A,n-sign(n)*c+=1), c, -c), A=setunion(A,[n]); S+=n); S} \\ _M. F. Hasler_, Mar 19 2019

%o (Python) def A248961(n):

%o A = {n}; c = 0; S = 0

%o while n != 0:

%o ++c; s = c if n>0 else -c; n += s if n-s in A else -s; A.add(n); S += n

%o return S # _M. F. Hasler_, Mar 19 2019

%Y Cf. A248939, A248973, A228474, A000217, A000330.

%K sign

%O 0,3

%A _Reinhard Zumkeller_, Oct 18 2014

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 April 18 20:10 EDT 2024. Contains 371781 sequences. (Running on oeis4.)