OFFSET
0,3
COMMENTS
The motivation for this kind of sequence was a question: what kind of simply defined non-injective functions f exist such that this sequence can be defined as their function, e.g., as a(n) = g(f(n)), where g is a nontrivial integer-valued function? The same question can also be asked about A324288, A324337 and A324338. Note that A005187, A283477 and A006068 used in their definitions are all injections. Of course, A324377(n) = A000265(A005187(n)) fills the bill as A002487(n) = A002487(A000265(n)), but are there any less obvious solutions? - Antti Karttunen, Feb 28 2019
LINKS
PROG
(PARI)
A002487(n) = { my(s=sign(n), a=1, b=0); n = abs(n); while(n>0, if(bitand(n, 1), b+=a, a+=b); n>>=1); (s*b); }; \\ Modified from the one given in A002487, sign not actually needed here.
A005187(n) = { my(s=n); while(n>>=1, s+=n); s; };
(Python)
from functools import reduce
def A324287(n): return sum(reduce(lambda x, y:(x[0], x[0]+x[1]) if int(y) else (x[0]+x[1], x[1]), bin((n<<1)-n.bit_count())[-1:2:-1], (1, 0))) if n else 0 # Chai Wah Wu, May 05 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 20 2019
STATUS
approved