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.

A318281 a(n+1) = a(n-a(n)) if a(n-1) != a(n), otherwise a(n+1) = a(n) + 3; a(1) = a(2) = a(3) = a(4) = 1.

This page as a plain text file.
%I A318281 #11 Oct 22 2018 14:08:17
%S A318281 1,1,1,1,4,1,4,1,4,4,7,1,7,1,7,1,7,4,1,4,1,4,4,7,7,10,1,10,4,7,4,1,4,
%T A318281 4,7,10,10,13,7,1,7,4,13,7,10,7,7,10,13,10,1,10,4,13,7,10,7,10,10,13,
%U A318281 7,13,13,16,10,7,10
%N A318281 a(n+1) = a(n-a(n)) if a(n-1) != a(n), otherwise a(n+1) = a(n) + 3; a(1) = a(2) = a(3) = a(4) = 1.
%C A318281 Sequences with an analogous condition a(n+1) = a(n) + s for s != 3 tend towards repetitive patterns:
%C A318281   for even values of s this is obvious, e.g.:
%C A318281     s = 2: 1,1,1,3,1,3,1,3,... (1,3 repeats)
%C A318281     s = 4: 1,1,1,1,1,5,1,5,1,5,1,5,... (1,5 repeats)
%C A318281   for odd values of s it has been checked up to s <= 19:
%C A318281     s = 1: 1,1,2,1,2,2,3,1,3,2,1,2,2,3,1,3,... (2,1,2,2,3,1,3 repeats)
%C A318281     s = 5: settles to a repetitive pattern of 192 terms
%C A318281     s = 7: settles to a repetitive pattern of 25 terms
%C A318281     s = 9: settles to a repetitive pattern of 31 terms
%C A318281     s = 11: settles to a repetitive pattern of 37 terms
%C A318281     s = 13: settles to a repetitive pattern of 43 terms
%C A318281     s = 15: settles to a repetitive pattern of 49 terms
%C A318281     s = 17: settles to a repetitive pattern of 55 terms
%C A318281     s = 19: settles to a repetitive pattern of 61 terms
%C A318281   It appears that for further values of s such sequences settle to a repetitive pattern of 4 + 3*s terms.
%H A318281 Rok Cestnik, <a href="/A318281/b318281.txt">Table of n, a(n) for n = 1..9999</a>
%e A318281 a(5) = a(4) + 3 = 4, because a(3) == a(4).
%e A318281 a(6) = a(5-a(5)) = a(1) = 1, because a(4) != a(5).
%o A318281 (C)
%o A318281 #include<stdio.h>
%o A318281 #include<stdlib.h>
%o A318281 #include<math.h>
%o A318281 int main(void){
%o A318281   int N = 100; //number of terms
%o A318281   int *a = (int*)malloc((N+1)*sizeof(int));
%o A318281   printf("1 1\n2 1\n3 1\n4 1\n");
%o A318281   a[1] = 1;
%o A318281   a[2] = 1;
%o A318281   a[3] = 1;
%o A318281   a[4] = 1;
%o A318281   for(int i = 4; i < N; ++i){
%o A318281     if(a[i-1] != a[i]) a[i+1] = a[i-a[i]];
%o A318281     else a[i+1] = a[i]+3;
%o A318281     printf("%d %d\n", i+1, a[i+1]);
%o A318281   }
%o A318281   free(a);
%o A318281   return 0;
%o A318281 }
%Y A318281 See A318282 for (a(n)-1)/3.
%Y A318281 Cf. A281130, A291598, A004001, A005085, A005229.
%K A318281 nonn
%O A318281 1,5
%A A318281 _Rok Cestnik_, Aug 23 2018