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!)
A270841 a(1) = 5; a(n) is the sum of |a(m) - m| for m < n. 2

%I #28 Apr 04 2016 11:52:22

%S 5,4,6,9,14,23,40,73,138,267,524,1037,2062,4111,8208,16401,32786,

%T 65555,131092,262165,524310,1048599,2097176,4194329,8388634,16777243,

%U 33554460,67108893,134217758,268435487,536870944,1073741857,2147483682,4294967331,8589934628

%N a(1) = 5; a(n) is the sum of |a(m) - m| for m < n.

%H Colin Barker, <a href="/A270841/b270841.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (4,-5,2).

%F For n > 2, a(n) = a(n - 2) + |a(n - 1) - (n - 1)|

%F For n > 2, a(n) = 2^(n - 2) + n + 1. - _Peter Kagey_, Mar 25 2016

%F From _Colin Barker_, Mar 28 2016: (Start)

%F a(n) = 4*a(n-1)-5*a(n-2)+2*a(n-3) for n>4.

%F G.f.: x*(5-16*x+15*x^2-5*x^3) / ((1-x)^2*(1-2*x)).

%F (End)

%e a(1) = 5;

%e a(2) = 4 because |a(1) - 1| = 4

%e a(3) = 6 because |a(2) - 2| + |a(1) - 1| = 6

%e a(4) = 9 because |a(3) - 3| + |a(2) - 2| + |a(1) - 1| = 9

%e (...)

%t a[1] := 5

%t a[n_]:= 2^(n - 2) + n + 1 (* _Peter Kagey_, Mar 25 2016 *)

%o (Java)

%o public static int[] a(int n) {

%o int[] terms = new int[n];

%o terms[0] = 0;

%o terms[1] = 5;

%o for (int i = 2; i < n; i++) {

%o int count = 0;

%o for (int j = 0; j < i; j++) {

%o count = count + abs(j - terms[j]);

%o }

%o terms[i] = count;

%o }

%o return terms;

%o }

%o (Ruby)

%o def a270841(n); n == 1 ? 5 : 2**(n - 2) + n + 1 end

%o # _Peter Kagey_, Mar 25 2016

%o (PARI) Vec(x*(5-16*x+15*x^2-5*x^3)/((1-x)^2*(1-2*x)) + O(x^50)) \\ _Colin Barker_, Mar 28 2016

%o (PARI) a(n)=if(n>1, 2^(n-2)+n+1, 5) \\ _Charles R Greathouse IV_, Mar 28 2016

%K easy,nonn

%O 1,1

%A _Alec Jones_, Mar 23 2016

%E More terms from _Colin Barker_, Mar 28 2016

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 May 4 21:32 EDT 2024. Contains 372257 sequences. (Running on oeis4.)