login
A291598
a(n) = log_2(A281130(n)).
5
0, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 3, 4, 4, 5, 2, 3, 4, 2, 3, 3, 4, 2, 3, 2, 3, 4, 4, 5, 4, 5, 3, 4, 3, 4, 2, 3, 5, 2, 3, 3, 4, 3, 4, 4, 5, 4, 5, 2, 3, 4, 4, 5, 3, 4, 2, 3, 2, 3, 4, 4, 5, 4, 5, 3, 4, 3, 4, 4, 5, 5, 6
OFFSET
1,7
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[Log2@ a@ # &, 105] (* Michael De Vlieger, Aug 29 2017 *)
PROG
(C)
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
int N = 100;
int *a = (int*)malloc((N+1)*sizeof(int));
printf("1 0\n2 0\n");
a[1] = 0;
a[2] = 0;
for(int i = 2; i < N; ++i){
if(a[i-1] < a[i]) a[i+1] = a[i-int(pow(2, a[i]))];
else a[i+1] = a[i]+1;
printf("%d %d\n", i+1, a[i+1]);
}
return 0;
}
CROSSREFS
Sequence in context: A097848 A308964 A124830 * A287820 A191373 A322873
KEYWORD
nonn
AUTHOR
Rok Cestnik, Aug 27 2017
STATUS
approved