OFFSET
1,4
COMMENTS
For the interesting properties of this sequence and A379184, see the article "Finding missing gems amidst chaos".
LINKS
Brad Klee, Finding missing gems amidst chaos, Wolfram Community, 2024.
Bradley Klee, Script for generating plaintext call tree (BASH)
Bradley Klee, Script for generating plaintext call tree (Golang)
Bradley Klee, Call tree (Golang output)
Stephen Wolfram, Nestedly Recursive Functions, 2024.
FORMULA
a(n) ~ n/phi.
MAPLE
a:= proc(n) option remember; `if`(n<4, signum(n-1), n-a(a(n-2))) end:
seq(a(n), n=1..76); # Alois P. Heinz, Dec 21 2024
MATHEMATICA
Block[{a}, a[1]=0; a[2]=a[3]=1; a[n_]:=a[n]=n-a[a[n-2]]; a/@Range[50]]
PROG
(PARI)
a(n)={my(b); b=vector(n); for(n=1, n, b[n]=if(
n==1, 0, n==2, 1, n==3, 1, n-b[b[n-2]])); b[n]}
(Go)
func a(n int) int {
b := make([]int, n+1);
copy(b, []int{0, 0, 1, 1});
for i:=4; i < n+1; i++ {
b[i] = i-b[b[i-2]];
};
return b[n]
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Bradley Klee, Dec 17 2024
STATUS
approved