# [seqfan] Re: Wavy Simple Recursion Involving Minimum

Joerg Arndt arndt at jjj.de
Thu Jul 30 01:55:44 CEST 2009

```N=40; A=vector(N);
\\ a(0)=0, a(1)=1, a(2)=2. For n>=3, a(n) = a(n-1) - min(a(n-2),a(n-3))
A[1]=0; A[2]=1; A[3]=2;  \\ note arrays start with index 1 in pari/gp
for(n=4, N, A[n] = A[n-1] - min(A[n-2],A[n-3]) );

V=[0,1,2,2,1,1,2,1,1,3,4,3,0,3,3,0,3,6,6,3, 0,1,2,2,1,-1,-2,-1,1,3,4,3,0,-3,-3,0,3,6,6,3]
A
V-A

V is what you submitted and that appears to be WRONG:

? V=[0,1,2,2,1,1,2,1,1,3,4,3,0,3,3,0,3,6,6,3,0,1,2,2,1,-1,-2,-1,1,3,4,3,0,-3,-3,0,3,6,6,3]
? A
[0, 1, 2, 2, 1, -1, -2, -1, 1, 3, 4, 3, 0, -3, -3, 0, 3, 6, 6, 3, -3, -6, -3, 3, 9, 12, 9, 0, -9, -9, 0, 9, 18, 18, 9, -9, -18, -9, 9, 27]
? V-A
[0, 0, 0, 0, 0, 2, 4, 2, 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 3, 7, 5, -1, -8, -13, -11, -1, 10, 12, 4, -6, -18, -21, -12, 9, 21, 15, -3, -24]

...also more terms should be included:

0, 1, 2, 2, 1, -1, -2, -1, 1, 3, 4, 3, 0, -3, -3, 0, 3, 6, 6, 3, -3,
-6, -3, 3, 9, 12, 9, 0, -9, -9, 0, 9, 18, 18, 9, -9, -18, -9, 9, 27,
36, 27, 0, -27, -27, 0, 27, 54, 54, 27, -27, -54, -27, 27, 81, 108,
81, 0, -81, -81, 0, 81, 162, 162, 81, -81, -162, -81, 81, 243, 324,
243, 0, -243, -243, 0, 243, 486, 486, 243, -243, -486, -243, 243, 729,
972, 729, 0, -729, -729, 0, 729, 1458, 1458, 729, -729, -1458, -729,
729, 2187

This did cost me less than 3 minutes.

If you are not willing to invest this time for your seqs
they are definitely not worth being submitted alltogether.

```