Want 3 consecutive integers?
Take 4 consecutive terms!
Hello SeqFans,
I must have missed
the correct entry in the OEIS because I cannot find this easy (core?) seq.
"To find 3
consecutive naturals in S, you have to take 4 consecutive terms of S -- no
less":
S =
1,3,0,2,4,1,3,5,2,4,6,3,5,7,4,6,8,5,7,9,6,8,10,7,9,11,8,10,12,9,11,13,10,12,14,11,13,15,12,14,16,13,15,17,14,16,18,15,...
Ex: taking the
first 3 terms doesn’t allow you to handle 3 consecutive natural numbers as they
are 0,1 and... 3.
But if you take
the fourth term (2), you’ll have in hand 0,1,2 [and
even another triplet of consecutive naturals, which is (1,2,3)].
Formula is easy to
compute.
Best,
E.
__________
Alex M.
Simplest formula I
could get: a(3n)=n-1; a(3n+1)=n+1; a(3n+2)=n+3. Or, a(n)=1+a(n-3).
__________
Richard Mathar:
Confirming Alex we
see that this falls into the pattern
a(n)= +a(n-1)
+a(n-3) -a(n-4) = (n+3+5*A049347(n-1))/3
(assuming offset 0)
also
known as the ocean of
<a href="Sindx_Rea.html#recLCC">Index
to sequences with linear recurrences with constant coefficients</a>,
signature (1,0,1,-1).
Generating
function
(1+2*x+x^3-3*x^2)/(1+x+x^2)/(x-1)^2
These
almost-no-growth sequences are bad for the economy.
RJM
__________
Alexander P-sky:
PURRS Demo Results
Verified exact
solution for x(n) = 1+x(-3+n) for the initial
conditions
x(0) = 1
x(1) = 3
x(2) = 0
Verified solution x(n) =
1+1/3*n-(1/18*I)*sqrt(3)*(-1/2+(1/2*I)*sqrt(3))^n+1/2*(-1/2-(1/2*I)*sqrt(3))^n+1
/2*(-1/2+(1/2*I)*sqrt(3))^n+(1/18*I)*sqrt(3)*(-1/2-(1/2*I)*sqrt(3))^n+(-1/2-(1/2
*I)*sqrt(3))^(-1)*(-1/2-(1/2*I)*sqrt(3))^n+(-1/2+(1/2*I)*sqrt(3))^(-1)*(-1/2+(1
/2*I)*sqrt(3))^n
for each n >= 0
---
PURRS Demo Results
Verified exact
solution for x(n) = x(-1+n)-x(-4+n)+x(-3+n) for the
initial conditions
x(0) = 1
x(1) = 3
x(2) = 0
x(3) = 2
Verified solution
x(n) =
1+1/3*n-(5/9*I)*sqrt(3)*(-1/2+(1/2*I)*sqrt(3))^n+(5/9*I)*sqrt(3)*(-1/2-(1/2*I)*sqrt(3))^n
for each n >= 0
Computing the
exact solution took about 61 ms of CPU time; verifying it took about 19 ms of
CPU time.
__________
S building method
is easy:
S = 1,3,0,2,4,1,3,5,2,4,6,3,5,7,4,6,8,5,7,9,6,8,10,7,9,11,8,10,12,9,11,13,10,12,14,11,13,15,12,14,16,13,15,17,14,16,18,15,...
S = 1,3,0,2,4,1,3,5,2,4,6,3,5,7,4,6,8,5,7,9,6,8,10,7,9,11,8,10,12,9,11,13,10,12,14,11,13,15,12,14,16,13,15,17,14,16,18,15,...
S = 1,3,0,2,4,1,3,5,2,4,6,3,5,7,4,6,8,5,7,9,6,8,10,7,9,11,8,10,12,9,11,13,10,12,14,11,13,15,12,14,16,13,15,17,14,16,18,15,...
Best,
Thanks to all,
É.