%I #13 Aug 08 2021 14:00:45
%S 1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
%T 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
%U 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
%N a(n) = 1 if n is a pentanacci number, 0 otherwise; characteristic function for A001591.
%H Antti Karttunen, <a href="/A296209/b296209.txt">Table of n, a(n) for n = 0..65537</a>
%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>
%t With[{pn=LinearRecurrence[{1,1,1,1,1},{0,0,0,0,1},15]},Table[ If[ MemberQ[ pn,n],1,0],{n,0,150}]] (* _Harvey P. Dale_, Aug 08 2021 *)
%o (PARI) A296209(n) = { if(n<=1,return(1)); my(p0=0,p1=0,p2=0,p3=1,p4=1,old_p0); while(n>p4,old_p0=p0;p0=p1;p1=p2;p2=p3;p3=p4;p4=old_p0+p0+p1+p2+p3;); (n==p4); }
%o (Scheme)
%o (define (A296209 n) (let loop ((i 3)) (if (< (A001591 i) n) (loop (+ 1 i)) (if (= (A001591 i) n) 1 0))))
%o ;; This uses memoization-macro definec:
%o (definec (A001591 n) (cond ((<= n 3) 0) ((= 4 n) 1) (else (+ (A001591 (- n 1)) (A001591 (- n 2)) (A001591 (- n 3)) (A001591 (- n 4)) (A001591 (- n 5))))))
%Y Cf. A001591, A288120.
%Y Cf. also A010056, A102460, A147612, A294878.
%K nonn
%O 0
%A _Antti Karttunen_, Dec 22 2017
|