cp's OEIS Frontend

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.

A248961 Sums of wrecker ball sequences starting with n.

This page as a plain text file.
%I A248961 #11 May 16 2019 01:32:32
%S A248961 0,1,-2,5,-292,-241,14,-437861,-28,-1,30,313,-4472,-4223,-2,55,3252,
%T A248961 -214246256269,-70,-27,5260887648,91,-538,-193,-132,-864538549823,-22,
%U A248961 27,140,40053,53088613819206,86166834699,86167898716,86168962733,86170026754,49,204
%N A248961 Sums of wrecker ball sequences starting with n.
%C A248961 a(n) = A248973(n, A228474(n)) = sum of row n in triangle A248939;
%C A248961 a(A000217(n)) = A000330(n).
%H A248961 Reinhard Zumkeller, <a href="/A248961/b248961.txt">Table of n, a(n) for n = 0..1000</a>
%H A248961 Gordon Hamilton, <a href="http://www.youtube.com/watch?v=mQdNaofLqVc">Wrecker Ball Sequences</a>, Video, 2013
%e A248961 a(1) = 1+0 = 1;
%e A248961 a(2) = 2+1-1-4+0 = -2;
%e A248961 a(3) = 3+2+0 = 5;
%e A248961 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 A248961 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 A248961 a(6) = 6+5+3+0 = 14;
%e A248961 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 A248961 a(8) = 8+7+5+2-2+3-3+4-4-13-23-12+0 = -28;
%e A248961 a(9) = 9+8+6+3-1+4-2+5-3-12-22-11+1+14+0 = -1.
%o A248961 (Haskell) import Data.IntSet (singleton, member, insert)
%o A248961 a248961 n = addup 1 n 0 $ singleton n where
%o A248961    addup _ 0 sum _ = sum
%o A248961    addup k x sum s = addup (k + 1) y (sum + x) (insert y s) where
%o A248961                      y = x + (if (x - j) `member` s then j else -j)
%o A248961                      j = k * signum x
%o A248961 (C++) #include<set>
%o A248961 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 A248961 (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 A248961 (Python) def A248961(n):
%o A248961   A = {n}; c = 0; S = 0
%o A248961   while n != 0:
%o A248961     ++c; s = c if n>0 else -c; n += s if n-s in A else -s; A.add(n); S += n
%o A248961   return S # _M. F. Hasler_, Mar 19 2019
%Y A248961 Cf. A248939, A248973, A228474, A000217, A000330.
%K A248961 sign
%O A248961 0,3
%A A248961 _Reinhard Zumkeller_, Oct 18 2014