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.

A209640 Global ranking function for restricted totally balanced binary strings given in A209641.

This page as a plain text file.
%I A209640 #16 Jul 01 2025 15:14:54
%S A209640 0,0,1,0,0,0,0,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
%T A209640 0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,5,0,6,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,
%U A209640 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,0,0,0,0,0,0,0,0
%N A209640 Global ranking function for restricted totally balanced binary strings given in A209641.
%C A209640 The given Scheme-program implements a ranking function for the terms of A209641, using Khayyam's triangle A007318.
%e A209640 a(12)=3, as 12 occurs as the 3rd term (zero-based) in A209641.
%e A209640 a(14)=0, as 14 doesn't occur in A209641.
%o A209640 (Scheme) (define (A209640 n) (if (or (zero? n) (not (member_of_A209641? n))) 0 (let* ((w (/ (binwidth n) 2))) (let loop ((rank 0) (row 1) (u (- w 1)) (n (- n (A053644 n))) (i (/ (A053644 n) 2)) (first_0_found? #f)) (cond ((or (zero? row) (zero? u) (zero? n)) (+ (expt 2 (-1+ w)) rank)) ((> i n) (loop rank (- row 1) u n (/ i 2) #t)) (else (loop (+ rank (if first_0_found? (A007318tr (- (+ row u) 1) (- row 1)) (A007318tr (- w 1) (- row 1)))) (+ row 1) (- u 1) (- n i) (/ i 2) first_0_found?)))))))
%o A209640 (define (binwidth n) (let loop ((n n) (i 0)) (if (zero? n) i (loop (floor->exact (/ n 2)) (1+ i)))))
%Y A209640 This is an inverse function for A209641 in the sense that a(A209641(n)) = n for all n. The beginning of sequence coincides with A080300, because A209641 is a subsequence of A014486. Used to compute the permutation A209861.
%K A209640 nonn
%O A209640 0,11
%A A209640 _Antti Karttunen_, Mar 24 2012