cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A287730 The s-fusc function s(n) = a(n): a(1) = 0, a(2n) = A287729(n), a(2n+1) = A287729(n) + A287729(n+1).

This page as a plain text file.
%I A287730 #91 Jul 27 2024 09:39:38
%S A287730 0,1,1,0,1,1,2,1,3,2,3,1,2,1,1,0,1,1,2,1,3,2,3,1,4,3,5,2,5,3,4,1,5,4,
%T A287730 7,3,8,5,7,2,7,5,8,3,7,4,5,1,4,3,5,2,5,3,4,1,3,2,3,1,2,1,1,0,1,1,2,1,
%U A287730 3,2,3,1,4,3,5,2,5,3,4,1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5,1,6,5,9,4
%N A287730 The s-fusc function s(n) = a(n): a(1) = 0, a(2n) = A287729(n), a(2n+1) = A287729(n) + A287729(n+1).
%C A287730 Define a sequence chf(n) of Christoffel words over an alphabet {-,+}:
%C A287730   chf(1) = '-',
%C A287730   chf(2*n+0) = negate(chf(n)),
%C A287730   chf(2*n+1) = negate(concatenate(chf(n),chf(n+1))).
%C A287730 Then the length of the chf(n) word is fusc(n) = A002487(n), the number of '-'-signs in the chf(n) word is c-fusc(n) = A287729(n) and the number of '+'-signs in the chf(n) word is the current sequence a(n) = s-fusc(n). See examples below.
%H A287730 I. V. Serov (terms 1..1025) & Antti Karttunen, <a href="/A287730/b287730.txt">Table of n, a(n) for n = 1..8192</a>
%H A287730 <a href="/index/St#Stern">Index entries for sequences related to Stern's sequences</a>
%F A287730 The mutual diatomic recurrence pair c(n) (A287729) and s(n) (this sequence) are defined by c(1)=1, s(1)=0, c(2n) = s(n), c(2n+1) = s(n)+s(n+1), s(2n) = c(n), s(2n+1) = c(n)+c(n+1).
%F A287730 a(n) + A287729(n) = A002487(n). [s-fusc(n) + c-fusc(n) = fusc(n).]
%F A287730 gcd(a(n), A287729(n)) = gcd(a(n), A002487(n)) = 1.
%F A287730 Let k(n) = A037227(n) = 1 + 2*A007814(n) = 1 + 2*floor(A002487(n-1)/A002487(n)) for n > 1.
%F A287730 Let d(n) = 2*A255738(n)*(-1)^A070939(n) = 2*(n==2^(A070939(n)-1)+1)*(-1)^A070939(n) = 2*(n==A053644(n)+1)*(-1)^A070939(n) = 2*(A002487(n-1)==1)*(-1)^A070939(n) for n > 1;
%F A287730 then a(n) = k(n-1)*a(n-1) - a(n-2) - d(n) for n > 2 with a(1) = 0, a(2) = 1.
%e A287730 n         chf(n) A070939(n) A002487(n) A287729(n)    a(n)
%e A287730                                 fusc       c-fusc     s-fusc
%e A287730 1          '-'       1          1          1          0
%e A287730 2          '+'       2          1          0          1
%e A287730 3          '+-'      2          2          1          1
%e A287730 4          '-'       3          1          1          0
%e A287730 5          '--+'     3          3          2          1
%e A287730 6          '-+'      3          2          1          1
%e A287730 7          '-++'     3          3          1          2
%e A287730 8          '+'       4          1          0          1
%e A287730 9          '+++-'    4          4          1          3
%e A287730 10         '++-'     4          3          1          2
%e A287730 11         '++-+-'   4          5          2          3
%e A287730 12         '+-'      4          2          1          1
%e A287730 13         '+-+--'   4          5          3          2
%e A287730 14         '+--'     4          3          2          1
%e A287730 15         '+---'    4          4          3          1
%e A287730 16         '-'       5          1          1          0
%e A287730 17         '----+'   5          5          4          1
%o A287730 (Scheme) (definec (A287730 n) (cond ((= 1 n) 0) ((even? n) (A287729 (/ n 2))) (else (+ (A287729 (/ (- n 1) 2)) (A287729 (/ (+ n 1) 2))))))
%o A287730 ;; An implementation of memoization-macro definec can be found for example in: http://oeis.org/wiki/Memoization
%o A287730 ;; Second version after the alternative formula given by the author:
%o A287730 (definec (A287730 n) (if (<= n 2) (- n 1) (- (* (A037227 (- n 1)) (A287730 (- n 1))) (A287730 (- n 2)) (* (if (= 1 (A002487 (- n 1))) 1 0) 2 (expt -1 (A070939 n)))))) ;; _Antti Karttunen_, Jun 01 2017
%o A287730 (Python)
%o A287730 from sympy.core.cache import cacheit
%o A287730 @cacheit
%o A287730 def c(n): return 1 if n==1 else s(n//2) if n%2==0 else s((n - 1)//2) + s((n + 1)//2)
%o A287730 @cacheit
%o A287730 def s(n): return 0 if n==1 else c(n//2) if n%2==0 else c((n - 1)//2) + c((n + 1)//2)
%o A287730 print([s(n) for n in range(1, 101)]) # _Indranil Ghosh_, Jun 08 2017
%Y A287730 Cf. A002487, A007814, A070939, A037227, A287729, A053644.
%Y A287730 Cf. mutual recurrence pair A000360, A284556 and also A213369.
%K A287730 nonn,look
%O A287730 1,7
%A A287730 _I. V. Serov_, May 30 2017