OFFSET
1,3
COMMENTS
The sequence is well defined, namely a(n) < n (with the exception of a(1)). Proof: Suppose a(s) = s+m, with m >= 0, is the first occurrence of a(n) >= n. It follows that a(s-1) = a(s-2) = (s+m)/2 and from there it follows that a(s-2-(s+m)/2) = (s+m)/2, but s-2-(s+m)/2 < (s+m)/2 which is a contradiction to the first statement. - Rok Cestnik, Aug 29 2017
From Robert G. Wilson v, Jan 16 2017: (Start)
a(n) = 2^k, k >= 0.
a(n)=1 for n: 1, 2, 4;
a(n)=2 for n: 3, 5, 6, 8, 10, 14;
a(n)=4 for n: 7, 9, 11, 12, 15, 16, 18, 20, 24, 28, 32, 42, 45, 49, 51, 62, 65, 75, 82, 84, 101, 108, 110, 118, 127, 175, 240;
First occurrence of 2^k (A281131): 1, 3, 7, 13, 23, 41, 98, 223, 437, 699, 1213, 2624, 4674, 11163, 21300, 40858, 73977, etc.;
Last occurrence of 2^k: 4, 14, 240, 1314, 10565, 35893, 62417, 638149, 2030926, etc.;
Number of occurrences of 2^k: 3, 6, 27, 77, 167, 330, 706, 1756, 3811, etc.
(End)
LINKS
Rok Cestnik, Table of n, a(n) for n = 1..10000
Rok Cestnik, Self-referencing visualization
EXAMPLE
a(3) = 2*a(2) = 2 because a(1) !< a(2).
a(4) = a(3-a(3)) = 1 because a(2) < a(3).
MATHEMATICA
a[n_] := a[n] = If[a[n -2] < a[n -1], a[n -1 -a[n -1]], 2 a[n -1]]; a[1] = a[2] = 1; Array[a, 100]
PROG
(C)
#include<stdio.h>
#include<stdlib.h>
int main(void){
int N = 1000;
int *a = (int*)malloc((N+1)*sizeof(int));
printf("1 1\n2 1\n");
a[1] = 1;
a[2] = 1;
for(int i = 2; i < N; ++i){
if(a[i-1] < a[i]) a[i+1] = a[i-a[i]];
else a[i+1] = 2*a[i];
printf("%d %d\n", i+1, a[i+1]);
}
return 0;
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Rok Cestnik, Jan 15 2017
STATUS
approved