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
5, 4, 6, 9, 14, 23, 40, 73, 138, 267, 524, 1037, 2062, 4111, 8208, 16401, 32786, 65555, 131092, 262165, 524310, 1048599, 2097176, 4194329, 8388634, 16777243, 33554460, 67108893, 134217758, 268435487, 536870944, 1073741857, 2147483682, 4294967331, 8589934628 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
FORMULA
For n > 2, a(n) = a(n - 2) + |a(n - 1) - (n - 1)|
For n > 2, a(n) = 2^(n - 2) + n + 1. - Peter Kagey, Mar 25 2016
From Colin Barker, Mar 28 2016: (Start)
a(n) = 4*a(n-1)-5*a(n-2)+2*a(n-3) for n>4.
G.f.: x*(5-16*x+15*x^2-5*x^3) / ((1-x)^2*(1-2*x)).
(End)
EXAMPLE
a(1) = 5;
a(2) = 4 because |a(1) - 1| = 4
a(3) = 6 because |a(2) - 2| + |a(1) - 1| = 6
a(4) = 9 because |a(3) - 3| + |a(2) - 2| + |a(1) - 1| = 9
(...)
MATHEMATICA
a[1] := 5
a[n_]:= 2^(n - 2) + n + 1 (* Peter Kagey, Mar 25 2016 *)
PROG
(Java)
public static int[] a(int n) {
int[] terms = new int[n];
terms[0] = 0;
terms[1] = 5;
for (int i = 2; i < n; i++) {
int count = 0;
for (int j = 0; j < i; j++) {
count = count + abs(j - terms[j]);
}
terms[i] = count;
}
return terms;
}
(Ruby)
def a270841(n); n == 1 ? 5 : 2**(n - 2) + n + 1 end
# Peter Kagey, Mar 25 2016
(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
(PARI) a(n)=if(n>1, 2^(n-2)+n+1, 5) \\ Charles R Greathouse IV, Mar 28 2016
CROSSREFS
Sequence in context: A347185 A345231 A335576 * A097995 A316670 A234745
KEYWORD
easy,nonn
AUTHOR
Alec Jones, Mar 23 2016
EXTENSIONS
More terms from Colin Barker, Mar 28 2016
STATUS
approved

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 24 11:14 EDT 2024. Contains 371936 sequences. (Running on oeis4.)