;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; http://www.iki.fi/~kartturi/matikka/Schemuli/intfun_b.scm ;; ;; - Often needed integer functions, the rest from old intfuns1.scm ;; ;; ;; ;; Coded by Antti Karttunen (my_firstname.my_surname@gmail.com), ;; ;; 2002-2012 ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (declare (usual-integrations)) ;; The rest: ;; Here are the 10 A-numbers you requested: A163233 --- A163242. (define (A163233bi x y) (+ (A000695 (A003188 x)) (* 2 (A000695 (A003188 y))))) (define (A163233 n) (A163233bi (A025581 n) (A002262 n))) ;; Inverse: (define (A163234 n) (packA001477 (A006068 (A059905 n)) (A006068 (A059906 n)))) ;; Transpose of A163233: (define (A163235 n) (A163233bi (A002262 n) (A025581 n))) ;; Inverse: (define (A163236 n) (packA001477 (A006068 (A059906 n)) (A006068 (A059905 n)))) (define (A163237 n) (A163241 (A163233 n))) (define (A163238 n) (A163234 (A163241 n))) (define (A163239 n) (A163241 (A163235 n))) (define (A163240 n) (A163236 (A163241 n))) (define (A163241 n) (+ (A000695 (A003987bi (A059905 n) (A059906 n))) (* 2 (A000695 (A059906 n))))) (define A163242 (ROWSUMS0 A163233)) ;; (0 3 18 30 90 153 204 252 492 735 990 1242 1446 1653 1848 2040 3000 3963 4938 5910 6930 7953 8964 9972 10788 11607 12438 13266 14046 14829 15600 16368 20208 24051 27906 31758 35658 39561 43452 47340 51420 55503 59598) ;; lsbs = Least Significant Trigits (define (complement-i-lsbs n i) (if (zero? i) n (+ (- 1 (modulo n 2)) (* 2 (complement-i-lsbs (floor->exact (/ n 2)) (-1+ i))) ) ) ) (define (complement-i-evenpos-lsbs n i) (if (zero? i) n (+ (- 1 (modulo n 2)) (* 2 (complement-i-oddpos-lsbs (floor->exact (/ n 2)) (-1+ i))) ) ) ) (define (complement-i-oddpos-lsbs n i) (+ (* 2 (complement-i-evenpos-lsbs (floor->exact (/ n 2)) i)) (modulo n 2) ) ) ;; Base 3 -> Base 9 conversion: (define (A037314 n) (if (< n 3) n (+ (modulo n 3) (* 9 (A037314 (floor->exact (/ n 3))))) ) ) ;; lsts = Least Significant Trigits (define (complement-i-lsts n i) (if (zero? i) n (+ (- 2 (modulo n 3)) (* 3 (complement-i-lsts (floor->exact (/ n 3)) (-1+ i))) ) ) ) (define (complement-i-evenpos-lsts n i) (if (zero? i) n (+ (- 2 (modulo n 3)) (* 3 (complement-i-oddpos-lsts (floor->exact (/ n 3)) (-1+ i))) ) ) ) (define (complement-i-oddpos-lsts n i) (+ (* 3 (complement-i-evenpos-lsts (floor->exact (/ n 3)) i)) (modulo n 3) ) ) ;; Here are the 20 A-numbers you requested: A163325 --- A163344. ;; Cf. A059905 (define (A163325 n) ;; Take the even-positioned trigits and contract them. (if (zero? n) n (+ (modulo n 3) (* 3 (A163325 (floor->exact (/ n 9))))) ) ) ;; Take the odd trigits and contract. Cf. A059906 (define (A163326 n) (A163325 (floor->exact (/ n 3)))) ;; Gives id (define (id n) (+ (A037314 (A163325 n)) (* 3 (A037314 (A163326 n))))) (define (A163327 n) (+ (A037314 (A163326 n)) (* 3 (A037314 (A163325 n))))) ;; Cf. A057300 (define (A163328 n) (+ (A037314 (A025581 n)) (* 3 (A037314 (A002262 n))))) ;; Cf. A054238 (define (A163329 n) (packA001477 (A163325 n) (A163326 n))) ;; Cf. A054239 ;; Transposes of above: (define (A163330 n) (+ (A037314 (A002262 n)) (* 3 (A037314 (A025581 n))))) (define (A163331 n) (packA001477 (A163326 n) (A163325 n))) (define (A163332 n) (let loop ((z 0) (n n) (i 0) ) (let ((x (modulo n 3)) (y (modulo (floor->exact (/ n 3)) 3)) ) (cond ((zero? n) z) ((and (= 1 x) (= 1 y)) ;; Central square, rotate everything 180 (loop (+ (* 4 (expt 3 i)) (complement-i-lsts z i)) (floor->exact (/ n 9)) (+ i 2) ) ) ((= 1 x) ;; either 01 or 21, complement odd-positioned trigits (loop (+ (* (+ (* y 3) 1) (expt 3 i)) (complement-i-oddpos-lsts z (/ i 2)) ) (floor->exact (/ n 9)) (+ i 2) ) ) ((= 1 y) ;; either 10 or 12, complement even-positioned trigits (loop (+ (* (+ 3 (- 2 x)) (expt 3 i)) ;; also x ! (complement-i-evenpos-lsts z (/ i 2)) ) (floor->exact (/ n 9)) (+ i 2) ) ) (else (loop (+ (* (+ (* y 3) x) (expt 3 i)) z) (floor->exact (/ n 9)) (+ i 2) ) ) ) ) ) ) ;; "Transposed", i.e. A163327-conjugate: (define (A163333 n) (A163327 (A163332 (A163327 n)))) ;; Hilbert II curve in a square array, zero-based (define (A163334 n) (A163332 (A163328 n))) ;; Inverse: (define (A163335 n) (A163329 (A163332 n))) ;; (map (lambda (n) (+ (abs (- (A025581 (A163358 (1+ n))) (A025581 (A163358 n)))) ;; (abs (- (A002262 (A163358 (1+ n))) (A002262 (A163358 n)))))) ;; (iota0 63)) ;; (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) ;; (map (lambda (n) (+ (abs (- (A025581 (A163335 (1+ n))) (A025581 (A163335 n)))) ;; (abs (- (A002262 (A163335 (1+ n))) (A002262 (A163335 n)))))) ;; (same-intfuns? A000012 (lambda (n) (+ (abs (- (A025581 (A163335 (1+ n))) (A025581 (A163335 n)))) ;; (abs (- (A002262 (A163335 (1+ n))) (A002262 (A163335 n)))))) ;; (expt 2 20)) ;; Hilbert II curve in a square array, zero-based, transposed (define (A163336 n) (A163332 (A163330 n))) (define (A163336v2 n) (A163327 (A163333 (A163328 n)))) (define (A163336v3 n) (A163334 (A061579 n))) ;; Inverse: (define (A163337 n) (A163331 (A163332 n))) (define (A163337v2 n) (A061579 (A163335 n))) ;; Hilbert II curve, one-based: (define (A163338 n) (+ 1 (A163334 (-1+ n)))) ;; Inverse: (define (A163339 n) (+ 1 (A163335 (-1+ n)))) ;; Hilbert II curve transposed, one-based: (define (A163340 n) (+ 1 (A163336 (-1+ n)))) ;; Inverse A163341: (define (A163341 n) (+ 1 (A163337 (-1+ n)))) (define A163342 (ROWSUMS0 A163334)) (define (A163343 n) (A163334 (A046092 n))) (define (A163343v2 n) (A163336 (A046092 n))) (define (A163344 n) (/ (A163343 n) 4)) ;; Here are the 11 A-numbers you requested: A163355 --- A163365. (definec (A163355 n) (let* ((i (floor->exact (/ (A000523 n) 2))) (dd (modulo (floor->exact (/ n (expt 4 i))) 4)) (r (if (zero? n) n (modulo n (expt 4 i)))) ) (cond ((zero? n) n) ;; ((= 0 dd) ;; 00xy --> 00xy ;; (format #t "I should not be here! Never executed!\n") ;; (A163355 r) ;; ) ((= (+ 1 (modulo i 2)) dd) ;; 01xy --> 01yx or 10xy --> 01yx (+ (expt 4 i) (A163355 (A057300 r))) ) ((= 3 dd) ;; 11xy --> 10yx (+ (* 2 (expt 4 i)) (A163355 (A057300 r))) ) (else ;; 10xy --> 11c(xy) or 01xy --> 11c(xy) (+ (* 3 (expt 4 i)) (A163355 (- (expt 4 i) 1 r)) ) ) ) ) ) (definec (A163356 n) (if (zero? n) n (let* ((i (floor->exact (/ (A000523 n) 2))) (d (modulo (floor->exact (/ n (expt 4 i))) 4)) (r (modulo n (expt 4 i))) ) (+ (* (-1+ (modulo (expt (+ 2 (modulo i 2)) d) 5)) (expt 4 i)) (cond ;; ((= 0 d) (A163356 r)) ;; Never encountered! ((= 3 d) (- (expt 4 i) 1 (A163356 r))) (else (A057300 (A163356 r))) ) ) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (A163355v2 n) ;; The older version. (let* ((i (A052928 (A000523 n))) (dd (modulo (floor->exact (/ n (expt 2 i))) 4)) (rest (if (zero? n) n (modulo n (expt 2 i)))) ) (cond ((zero? n) n) ((= 0 dd) ;; 00xy --> 00xy (A163355v2 rest) ) ((= 3 dd) ;; 11xy --> 10yx (+ (expt 2 (1+ i)) (A163355v2 (A057300 rest))) ) ((= (+ 1 (floor->exact (/ (modulo i 4) 2))) dd) ;; 01xy --> 01yx or 10xy --> 01yx (+ (expt 2 i) (A163355v2 (A057300 rest))) ) (else ;; 10xy --> 11c(xy) or 01xy --> 11c(xy) (+ (* 3 (expt 2 i)) (A163355v2 (- (expt 2 i) 1 rest)) ) ) ) ) ) ;; Older version: (define (A163356v2 n) (let loop ((z 0) (n n) (i 0) ) (let ((dd (modulo n 4))) (cond ((zero? n) z) ((= 0 dd) ;; 00xy --> 00xy (loop z (floor->exact (/ n 4)) (+ i 2) ) ) ((= 2 dd) ;; 10xy --> 11yx (loop (+ (* 3 (expt 2 i)) (A057300 z)) (floor->exact (/ n 4)) (+ i 2) ) ) ((= 1 dd) ;; 01xy --> 01yx or 01xy --> 10yx (loop (+ (expt 2 (+ i (floor->exact (/ (modulo i 4) 2)))) (A057300 z) ) (floor->exact (/ n 4)) (+ i 2) ) ) (else ;; 11xy --> 10c(xy) or 11xy --> 01c(xy) (loop (+ (expt 2 (+ i (- 1 (floor->exact (/ (modulo i 4) 2))))) (- (expt 2 i) z 1) ) (floor->exact (/ n 4)) (+ i 2) ) ) ) ) ) ) (define (range-of-nth-binary-forest n) (if (zero? n) (cons n n) (cons (A000079 (-1+ n)) (- (A000079 n) 1)) ) ) (define (indices-of-nth-binary-forest n) (if (zero? n) (list n) (map (lambda (x) (+ (A000079 (-1+ n)) x)) (iota0 (-1+ (A000079 (-1+ n))))) ) ) ;; From A000302(n) to A000302(n+1)-1, i.e. [1,3], [4,15], [16,63], [64,255], ;; i.e. A002001 = 1,3,12,48,192,768,3072,12288,49152,196608,786432,3145728, ;; a(n) = 3*4^(n-1), n>0; a(0)=1. (define (range-of-nth-quaternary-forest n) (if (zero? n) (cons n n) (cons (A000302 (-1+ n)) (+ (A000302 (-1+ n)) (-1+ (A002001 n)))) ) ) (define (indices-of-nth-quaternary-forest n) (if (zero? n) (list n) (map (lambda (x) (+ (A000302 (-1+ n)) x)) (iota0 (-1+ (A002001 n)))) ) ) ;; --- ;; ----------------------------------------------------------------- (define (partition-by-intpermAfun size intpermutation indfun) (let ((src_set (indfun size))) (let loop ((cur (car src_set)) (src src_set) (res (list (list)))) (cond ((null? src) (reverse! (map reverse! res))) ((member cur src) (loop (intpermutation cur) (delete! cur src) (cons (cons cur (car res)) (cdr res)) ) ) (else ;; Completed one whole cycle, let's begin the next one with the first ;; parenthesization we have left: (loop (car src) src (cons (list) res)) ) ) ; cond ) ; let loop ) ) (define (number-of-1-cycles cycles) (let ((fes 0)) (for-each (lambda (c) (if (and (pair? c) (not (pair? (cdr c)))) (set! fes (1+ fes))) ) cycles ) fes ) ) (define (num-of-ones cycles) (let ((fes 0)) (for-each (lambda (c) (if (= 1 c) (set! fes (1+ fes)))) cycles ) fes ) ) (define (fc-generic-Afun-very-inefficient Afun indfun) (lambda (n) (number-of-1-cycles (partition-by-intpermAfun n Afun indfun))) ) (define (fc-generic-Afun Afun rangefun) (lambda (n) (let ((rp (rangefun n))) (let loop ((s 0) (i (car rp))) (cond ((> i (cdr rp)) s) ((= (Afun i) i) (loop (1+ s) (1+ i))) ;; Found a fixed point! (else (loop s (1+ i))) ) ) ) ) ) (define (elements-on-even-orbits-generic-Afun Afun indfun) (lambda (n) (apply + (keep-matching-items (map length (partition-by-intpermAfun n Afun indfun)) even?))) ) (define (elements-on-odd-orbits-generic-Afun Afun indfun) (lambda (n) (apply + (keep-matching-items (map length (partition-by-intpermAfun n Afun indfun)) odd?))) ) (define (cc-generic-Afun Afun indfun) (lambda (n) (length (partition-by-intpermAfun n Afun indfun))) ) (define (mc-generic-Afun Afun indfun) (lambda (n) (apply max (map length (partition-by-intpermAfun n Afun indfun)))) ) (define (lc-generic-Afun Afun indfun) (lambda (n) (apply lcm (map length (partition-by-intpermAfun n Afun indfun)))) ) (define (compute-and-print-generic-count-seqs Afun indfun outfile upto-n) (call-with-output-file outfile (lambda (outport) (let loop ((n 0) (ccs (list 1)) (fcs (list 1)) (mcs (list 1)) (lcs (list 1)) ) (format #t "n=~A: ccs=~A fcs=~A mcs=~A lcs=~A~%" n ccs fcs mcs lcs ) (format outport "n=~A: ccs=~A fcs=~A mcs=~A lcs=~A~%" n ccs fcs mcs lcs ) (flush-output outport) (cond ((< n upto-n) (let ((partlengths (map length (partition-by-intpermAfun (1+ n) Afun indfun)))) (loop (1+ n) (append ccs (list (length partlengths))) (append fcs (list (num-of-ones partlengths))) (append mcs (list (fold-left max 0 partlengths))) (append lcs (list (fold-left lcm 1 partlengths))) ) ) ) ) ) ) ) ) (define (compute-and-print-cycle-vectors-for-A163355 outfile upto-n) (compute-and-print-generic-cycle-vectors A163355 indices-of-nth-quaternary-forest outfile upto-n ) ) (define (compute-and-print-generic-cycle-vectors Afun indfun outfile upto-n) (call-with-output-file outfile (lambda (outport) (let loop ((n 0) (partlengths (list 1)) ) (let ((ccs (list (length partlengths))) (fcs (list (num-of-ones partlengths))) (mcs (list (fold-left max 0 partlengths))) (lcs (list (fold-left lcm 1 partlengths))) (cpairs (multiset->countpairs partlengths)) ) (format #t "n=~A: ccs=~A fcs=~A mcs=~A lcs=~A, cycles, times*sizes=~A~%" n ccs fcs mcs lcs cpairs ) (format outport "n=~A: ccs=~A fcs=~A mcs=~A lcs=~A, cycles, times*sizes=~A~%" n ccs fcs mcs lcs cpairs ) (flush-output outport) (cond ((< n upto-n) (loop (1+ n) (map length (partition-by-intpermAfun (1+ n) Afun indfun))) ) ) ) ) ) ) ) (define (compute-and-print-one-by-one Afun outfile start upto-n) (call-with-output-file outfile (lambda (outport) (let loop ((n start) (z (Afun start))) (format #t "n=~A: ~A~%" n z) (format outport "~A ~A~%" n z) (flush-output outport) (cond ((< n upto-n) (loop (1+ n) (Afun (1+ n))))) ) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Here are the 30 A-numbers you requested: A163890 --- A163919. ;; orbit-size-of-n-under-A163355 (definec (A163890 n) (let loop ((i 1) (nn (A163355 n))) (cond ((= nn n) i) (else (loop (1+ i) (A163355 nn))) ) ) ) ;; Up to n=21 at least. (define A163891 (DISTINCT-POS 0 0 A163890)) ;; Might be a permutation of A003586 (A036561), or at least a subset of it: ;; (Where are for example 27 and 81 and 243?) ;; (define A163892 (DISTINCT-VALS 0 0 A163890)) (define (A163892 n) (A163890 (A163891 n))) ;; Let's use the cache of A163891. ;; (map A163892 (iota0 21)) ;; (1 2 6 3 4 8 12 18 9 16 32 24 108 36 48 54 72 64 96 192 216 324) ;; First differences of A163891, zero-based: (define (A163893 n) (- (A163891 (1+ n)) (A163891 n))) ;; First differing element between A001477 and A163355^n: ;; (0 if they do not differ). (definec (A163894 n) (if (zero? n) 0 (let loop ((i 1) (nth_power (compose-fun-to-nth-power A163355 n))) (cond ((not (= i (nth_power i))) i) (else (loop (1+ i) nth_power)) ) ) ) ) ;; At least up to n=8 or 12: (define A163895 (RECORD-POS 0 0 A163894)) ;; (define A163896 (RECORD-VALS 0 0 A163894)) (define (A163896 n) (A163894 (A163895 n))) ;; Let's use the same cache. (define (A163897 n) (- (A163531 n) (A163547 n))) ;; Table, distance of number n in A163357 from ;; its position in the basic grid A054238: ;; ;; (define (A054238 n) (+ (A000695 (A025581 n)) (* 2 (A000695 (A002262 n))))) ;; (define (A054239 n) (packA001477 (A059905 n) (A059906 n))) ;; Two tables (squares of distances): (define (A163898 n) (A163900 (A054238 n))) (define (A163899 n) (A163900 (A163357 n))) ;; Based on this function: (zeros occur at A163901). ;; Squared distance between n's location in A054238 grid and A163357 grid. (definec (A163900 n) (+ (A000290 (abs (- (A059906 n) (A059252 n)))) (A000290 (abs (- (A059905 n) (A059253 n)))) ) ) (define A163901 (MATCHING-POS 0 0 (lambda (i) (= i (A163355 i))))) (define A163902 (MATCHING-POS 0 0 (lambda (i) (and (not (= i (A163355 i))) (= i (A163355 (A163355 i))) ) ) ) ) (define A163903 (MATCHING-POS 0 0 (lambda (i) (and (not (= i (A163355 i))) (= i (A163355 (A163355 (A163355 i)))) ) ) ) ) ;; Table, cycle size of each n: ;; (1's occur at the same positions as the zeros of A163898 and A163899, i.e. A165403): (define (A163904 n) (A163890 (A054238 n))) (define (A163904v2 n) (A163890 (A163357 n))) ;; (define A165403 (MATCHING-POS 0 0 (lambda (i) (= 0 (A163898 i))))) ;; (define A165403v2 (MATCHING-POS 0 0 (lambda (i) (= 0 (A163899 i))))) (define A165403 (ZERO-POS 0 0 A163898)) (define A165403v2 (ZERO-POS 0 0 A163899)) (define A165403v3 (MATCHING-POS 0 0 (lambda (i) (= 1 (A163904 i))))) (define (A165404 n) (A025581 (A165403 n))) (define (A165406 n) (A007088 (A165404 n))) (define (A165406v2 n) (A007090 (A163901 n))) (define A163910 (cc-generic-Afun A163355 indices-of-nth-quaternary-forest)) (define A163911 (mc-generic-Afun A163355 indices-of-nth-quaternary-forest)) (define A163912 (lc-generic-Afun A163355 indices-of-nth-quaternary-forest)) ;; (map A163913 (iota0 13)) ;; (0 0 6 3 30 27 162 171 885 987 4839 5502 26436 30216) (definec (A163913 n) (let ((rp (range-of-nth-quaternary-forest n))) (let loop ((s 0) (i (car rp))) (cond ((> i (cdr rp)) s) ((and (not (= (A163355 i) i)) (= (A163915 i) i)) (loop (1+ s) (1+ i)) ) (else (loop s (1+ i))) ) ) ) ) ;; (0 0 2 1 10 9 54 57 295 329 1613 1834 8812 10072) (define (A163914 n) (/ (A163913 n) 3)) ;; Also two bisections, up to n=6: (define (A163909 n) (A163914 (* 2 n))) (define (A163919 n) (A163914 (1+ (* 2 n)))) (define (A163905 n) (A163355 (A163355 n))) (define (A163906 n) (A163356 (A163356 n))) (define (A163907 n) (A163905 (A054238 n))) (define (A163908 n) (A054239 (A163906 n))) (define (A163915 n) (A163355 (A163355 (A163355 n)))) (define (A163916 n) (A163356 (A163356 (A163356 n)))) (define (A163917 n) (A163915 (A054238 n))) (define (A163918 n) (A054239 (A163916 n))) ;; Midpoint height of "Jacobi-bridge", computed for each odd integer ;; of the form 4n+3. (definec (A165601 n) (let ((w (A004767 n))) ;; w = 4n+3 (add (lambda (i) (jacobi-symbol i w)) 0 (/ (-1+ w) 2)) ) ) (define A165602 (ZERO-POS 0 0 A165601)) ;; Positions of zeros in A165601. ;; Numbers of the form 4n+3 for which Sum_{i=0..(2n+1)} J(i/4n+3) = 0. (define (A165603 n) (A004767 (A165602 n))) (define (A165604 n) (A165601 (* 3 n))) ;; 12n+3 (define (A165605 n) (A165601 (+ 1 (* 3 n)))) ;; 12n+7 (A017605) (define (A165606 n) (A165601 (+ 2 (* 3 n)))) ;; 12n+11 ;; The height at the 1/3 point at "Jacobi-bridge", ;; computed for each odd integer of the form 12n+7 (definec (A165460 n) (let ((w (A017605 n))) ;; w = 12n+7 (add (lambda (i) (jacobi-symbol i w)) 0 (/ (-1+ w) 3)) ) ) (define A165461 (ZERO-POS 0 0 A165460)) ;; Positions of zeros in A165460. (define (A165462 n) (/ (- (A165463 n) 3) 4)) ;; Subset of A165602 ? ;; Numbers of the form 12n+7 for which Sum_{i=0..(4n+2)} J(i/12n+7) = 0. (define (A165463 n) (A017605 (A165461 n))) ;; Subset of A165603 ? ;; Here are the 10 A-numbers you requested: A165460 --- A165469. ;; Squared distance between n's location in A163334 grid and A163357 grid. ;; (equivalently: between n's location in A163336 grid and A163359 grid.) (definec (A165464 n) (+ (A000290 (abs (- (A163529 n) (A059252 n)))) (A000290 (abs (- (A163528 n) (A059253 n)))) ) ) (define A165465 (ZERO-POS 0 0 A165464)) ;; Positions of zeros in A165464. (definec (A165466 n) (+ (A000290 (abs (- (A163529 n) (A059253 n)))) (A000290 (abs (- (A163528 n) (A059252 n)))) ) ) (define A165467 (ZERO-POS 0 0 A165466)) ;; Positions of zeros in A165466. (define A095274 (MATCHING-POS 1 0 (lambda (n) (let ((w (A004767 n)) ;; w = 4n+3 (hp (A005408 n)) ;; hp = 2n+1 = ((w-1)/2) ) (let loop ((i 1) (s 1)) ;; s = sum of the first i Jacobi-symbols in [1,i] (cond ((< s 0) #f) ((>= i hp) #t) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)))) ) ) ) ) ) ) (define (A095100 n) (A004767 (A095274 n))) (define A095272 (MATCHING-POS 1 0 (lambda (n) (let ((w (A004767 n)) ;; w = 4n+3 (hp (A005408 n)) ;; hp = 2n+1 = ((w-1)/2) ) (and (not (zero? (A010051 w))) (let loop ((i 1) (s 1)) ;; s = sum of the first i Jacobi-symbols in [1,i] (cond ((< s 0) #f) ((>= i hp) #t) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)))) ) ) ) ) ) ) ) (define (A095102 n) (A004767 (A095272 n))) ;; Subset of A095274. (define A165468 (MATCHING-POS 1 0 (lambda (n) (let ((w (A004767 n)) ;; w = 4n+3 (hp (A005408 n)) ;; hp = 2n+1 = ((w-1)/2) ) (let loop ((i 1) (s 1)) ;; s = sum of the first i Jacobi-symbols in [1,i] (cond ((<= s 0) #f) ((>= i hp) #t) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)))) ) ) ) ) ) ) ;; Subset of A095100. (define (A165469 n) (A004767 (A165468 n))) ;; Subset of A095272. (define index_fun_for_A165580 (MATCHING-POS 1 0 (lambda (n) (let ((w (A004767 n)) ;; w = 4n+3 (hp (A005408 n)) ;; hp = 2n+1 = ((w-1)/2) ) (and (not (zero? (A010051 w))) (let loop ((i 1) (s 1)) ;; s = sum of the first i Jacobi-symbols in [1,i] (cond ((<= s 0) #f) ((>= i hp) #t) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)))) ) ) ) ) ) ) ) ;; Subset of A165468 and A095102. (define (A165580 n) (A004767 (index_fun_for_A165580 n))) ;; Difference A095274 \ A165468: ;; (Those n, for which Jacobi-bridge of 4n+3 visits sea level, but doesn't dive) (define A165607 (MATCHING-POS 1 0 (lambda (n) (let ((w (A004767 n)) ;; w = 4n+3 (hp (A005408 n)) ;; hp = 2n+1 = ((w-1)/2) ) ;; s = sum of the first i Jacobi-symbols in [1,i] (let loop ((i 1) (s 1) (zv 0)) ;; zv = # of sea level visits. (cond ((< s 0) #f) ;; Goes negative, fail. ((>= i hp) (not (zero? zv))) ((zero? s) (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) (1+ zv)) ) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) zv)) ) ) ) ) ) ) ;; A095100 \ A165469: (define (A165608 n) (A004767 (A165607 n))) (define index_fun_for_A165977 (MATCHING-POS 1 0 (lambda (n) (let ((w (A004767 n)) ;; w = 4n+3 (hp (A005408 n)) ;; hp = 2n+1 = ((w-1)/2) ) ;; s = sum of the first i Jacobi-symbols in [1,i] (and (not (zero? (A010051 w))) (let loop ((i 1) (s 1) (zv 0)) ;; zv = # of sea level visits. (cond ((< s 0) #f) ;; Goes negative, fail. ((>= i hp) (not (zero? zv))) ((zero? s) (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) (1+ zv)) ) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) zv)) ) ) ) ) ) ) ) ;; A095102 \ A165580: (define (A165977 n) (A004767 (index_fun_for_A165977 n))) ;; Here are the 20 A-numbers you requested: A166040 --- A166059. ;; Fixed points: A165465 (define (A166041 n) (A163357 (A163335 n))) (define (A166041v2 n) (A163359 (A163337 n))) (define (A166042 n) (A163334 (A163358 n))) (define (A166042v2 n) (A163336 (A163360 n))) ;; Fixed points: A165466 (define (A166043 n) (A163357 (A163337 n))) (define (A166043v2 n) (A163359 (A163335 n))) (define (A166044 n) (A163336 (A163358 n))) (define (A166044v2 n) (A163334 (A163360 n))) (define A166045 (RECORD-POS 0 0 A165601)) (define (A166046 n) (A004767 (A166045 n))) (define A166047 (RECORD-VALS 0 0 A165601)) ;; Cf. A112060, A112070 (definec (A166040 n) (let ((w (A005408 n))) ;; s = sum of the first i Jacobi-symbols in [1,i] (let loop ((i 1) (s 1) (zv 0)) ;; zv = # of sea level visits. (cond ((= i w) zv) ((zero? s) (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) (1+ zv)) ) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) zv)) ) ) ) ) (define A166048 (MATCHING-POS 1 0 (lambda (n) (let ((w (A016813 n)) ;; w = 4n+1 (hp (A005843 n)) ;; hp = 2n = ((w-1)/2) ) ;; s = sum of the first i Jacobi-symbols in [1,i] (let loop ((i 1) (s 1)) (cond ((< s 0) #f) ;; Goes negative, fail. ((>= i hp) #t) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)))) ) ) ) ) ) ) (define (A166049 n) (A016813 (A166048 n))) ;; Same without squares: (define index_for_A166051 (MATCHING-POS 1 0 (lambda (n) (let ((w (A016813c n)) ;; w = 4n+1 (hp (A005843 n)) ;; hp = 2n = ((w-1)/2) ) ;; s = sum of the first i Jacobi-symbols in [1,i] (let loop ((i 1) (s 1)) (cond ((< s 0) #f) ;; Goes negative, fail. ((>= i hp) (zero? s)) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)))) ) ) ) ) ) ) ;; A166049 without squares (is this finite? Cf. A080114). ;; At least 7 terms. (define (A166051 n) (A016813 (index_for_A166051 n))) ;; Here are the 20 A-numbers you requested: A166085 --- A166104. ;; Two bisections of A166040: (define (A166085 n) (A166040 (A005843 n))) ;; For searching among 4n+1 (define (A166086 n) (A166040 (A005408 n))) ;; and for amongst 4n+3 (define A046092v2 (MATCHING-POS 1 0 (lambda (i) (= 0 (A166040 i))))) (define (A016754v2 n) (A005408 (A046092v2 n))) ;; Odd squares. (define A165468v2 (MATCHING-POS 1 0 (lambda (i) (= 1 (A166086 i))))) (define (A165469v2 n) (A004767 (A165468v2 n))) ;; Yes. (define A166052 (MATCHING-POS 1 0 (lambda (i) (= 3 (A166086 i))))) (define (A166053 n) (A004767 (A166052 n))) (define A166054 (MATCHING-POS 1 0 (lambda (i) (= 5 (A166086 i))))) (define (A166055 n) (A004767 (A166054 n))) (define A166056 (MATCHING-POS 1 0 (lambda (i) (= 7 (A166086 i))))) (define (A166057 n) (A004767 (A166056 n))) (define A166058 (MATCHING-POS 1 0 (lambda (i) (= 9 (A166086 i))))) (define (A166059 n) (A004767 (A166058 n))) ;; At least 8 terms: (define index_for_A166088 (MATCHING-POS 1 0 (lambda (i) (= 8 (A166040 i))))) (define (A166088 n) (A005408 (index_for_A166088 n))) ;; First occurrence of n in A166040: Zero-based. (define A166087 (LEAST-I-WITH-FUN-I-EQ-N 0 0 A166040)) ;; Corresponding odd numbers: Zero-based. (define (A166089 n) (A005408 (A166087 n))) (define (A166091bi n k) (let ((m (A005408 k))) (let loop ((i 0) (n n)) (cond ((= m (A166086 i)) (if (zero? n) i (loop (1+ i) (-1+ n)) ) ) (else (loop (1+ i) n)) ) ) ) ) (definec (A166091 n) (A166091bi (A025581 n) (A002262 n))) (define (A166092 n) (A004767 (A166091 n))) ;; Corresponding 4k+3 integers. ;; ;; First 5 rows: A165469, A166053, A166055, A166057, A166059 (define A166093 (compose-funs (LEAST-I-WITH-FUN-I-EQ-N 0 0 A166085) A005843)) (define A166094 (compose-funs (LEAST-I-WITH-FUN-I-EQ-N 0 0 A166086) A005408)) ;; First column of A166091. (define (A166090 n) (A016813 (A166093 n))) ;; Two bisections of A166089: (define (A166095 n) (A166089 (A005843 n))) (define (A166096 n) (A166089 (A005408 n))) ;; First column of A166092. ;; NOT!: A166095 = A016813 A166093 (instead, we have A166090.) ;; A166096 = A004767 A166094 (define A166097 (DISTINCT-POS 0 0 A166040)) (defineperm1 (A166098 n) (A166040 (A166097 n))) (define A166098v2 (DISTINCT-VALS 0 0 A166040)) ;; Permutation of A001477? (define (A166099 n) (A166098 (- n))) ;; Offset 0. ;; The height at the 1/6 point at "Jacobi-bridge", ;; computed for each odd integer of the form 12n+7 ;; Compare to A165460. (definec (A166050 n) (let ((w (A017605 n))) ;; w = 12n+7 (add (lambda (i) (jacobi-symbol i w)) 0 (/ (-1+ w) 6)) ) ) (definec (A166100 n) (let ((w (A005408 n))) ;; w = 2n+1 (let loop ((i 1) (s 1)) (cond ((= i w) s) (else (loop (1+ i) (+ s (if (= +1 (jacobi-symbol (1+ i) w)) (1+ i) 0)) ) ) ) ) ) ) ;; Number of even numbers less than the n-th prime. ;; Same as A005097 ((odd primes - 1)/2) with a leading zero. ;; Offset 1, starts as: 0, 1, 2, 3, 5, 6, 8, 9, 11, 14, 15, 18, 20, 21, 23, ... (define (A102781 n) (if (= 1 n) 0 (/ (-1+ (A000040 n)) 2))) ;; Offset 1. (define (A076409 n) (A166100 (A102781 n))) ;; Offset 3. (define (A076410 n) (/ (A076409 n) (A000040 n))) ;; Offset 1. for A166101 - A166104. (define A166101 (MATCHING-POS 1 0 (lambda (n) (not (integer? (/ (A166100 n) (A005408 n)))))) ) ;; Conjecture: a(n) = 3*A166103(n). Checked for terms a(1)-a(92). (define (A166102 n) (A005408 (A166101 n))) (define (A166103 n) (A000290 (A166104 n))) (define (A166103v2 n) (/ (A166102 n) 3)) (define A166104 (MATCHING-POS 1 1 (lambda (n) (for-all? (factor n) (lambda (p) (or (= 1 p) (= 3 p) (= 5 (modulo p 6)))) ) ) ) ) (define (A166104v2 n) (sqrt (A166103 n))) (definec (A166272 n) (numerator (/ (A166100 (A166101 n)) (A166102 n)))) (definec (A166272v2 n) (* 3 (/ (A166100 (A166101 n)) (A166102 n)))) (definec (A166272v3 n) (* 3 (/ (A166100 (A166101 n)) (A005408 (A166101 n))))) (define A045410 ;; Primes congruent to {3, 5} mod 6. 3,5,11,17,23,29,41,47,... (compose-funs A000040 (MATCHING-POS 1 1 (lambda (n) (or (= 2 n) (= 5 (modulo (A000040 n) 6))))) ) ) ;; A125615(n)=a(A102781(n)). (definec (A166405 n) (let ((w (A005408 n))) ;; w = 2n+1 (let loop ((i 1) (s 0)) (cond ((= i w) s) (else (loop (1+ i) (+ s (if (= -1 (jacobi-symbol (1+ i) w)) (1+ i) 0)) ) ) ) ) ) ) (define (A166406 n) (- (A166405 n) (A166100 n))) (define (A166407 n) (* 3 (/ (A166406 n) (A005408 n)))) ;; A165951(n)=A166408(A102781(n)) for n>=2. (define (A166408 n) (floor->exact (/ (A166407 n) 3))) ;; Differs from A077425 for the first time at n=21, where a(n)=99, not 101. ;; I.e. seems to be union of A077425 & A165603: (define A166409 (compose-funs A005408 (ZERO-POS 1 0 A166406))) (define A165603v2 ;; Hmm... Prove it! (compose-funs A005408 (MATCHING-POS 1 0 (lambda (n) (and (zero? (A166406 n)) (odd? n) ) ) ) ) ) ;; Here are the 10 A-numbers you requested: A166268 --- A166277. (define (A166268 n) (A166050 (A005843 n))) (define (A166268v2 n) (A165605 (A005843 n))) ;; ??? (define (A166269 n) (A166050 (A005408 n))) ;; -1 -1 -1 -2 -2 -3 -1 (define (A166270 n) (A165460 (A005843 n))) ;; = 2*A166268(n) ??? (define (A166271 n) (A165460 (A005408 n))) ;; = -2 * A166269(n). = (* 2 (A001489 (A166269 n))) ??? (define (A166273 n) (A165605 (A005408 n))) ;; = -3 * A166269(n). = (* 3 (A001489 (A166269 n))) ??? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Here are the 20 A-numbers you requested: A166404 --- A166423. ;; Here are the 20 A-numbers you requested: A166424 --- A166443. (define (A166436 n) (A102283 (A163536 n))) (define (A166442 n) (A102283 (A163542 n))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Here are the 18 A-numbers you requested: A165471 --- A165488. ;; A000668: [3,7,31,127,8191,131071,524287,2147483647,...] ;; A019434: [3,5,17,257,65537] ;; A005478: [2,3,5,13,89,233,1597,28657,514229,...] ;; 5: A080891 ;; 7: ;; 13: A011583 ;; 17: A011584 ;; 31: A011588 ;; 89: A011601 ;; 127: A011608 ;; ;; 199: A011623 ;; 211: A011624 ;; 223: A011625 ;; 227: A011626 ;; 229: A011627 ;; 233: A011628 ;; 239: A011629 ;; 241: A011630 ;; 251: A011631 ;; 257: Not present. ;; 263: ;; 269: ;; 271: ;; 277: ;; 281: ;; 283: ;; 293: ;; 307: (define (A080891 n) (legendre-symbol n 5)) (define (A011583 n) (legendre-symbol n 13)) (define (A011584 n) (legendre-symbol n 17)) (define (A011588 n) (legendre-symbol n 31)) (define (A011601 n) (legendre-symbol n 89)) (define (A011608 n) (legendre-symbol n 127)) (define (A011623 n) (legendre-symbol n 199)) (define (A011624 n) (legendre-symbol n 211)) (define (A011625 n) (legendre-symbol n 223)) (define (A011626 n) (legendre-symbol n 227)) (define (A011627 n) (legendre-symbol n 229)) (define (A011628 n) (legendre-symbol n 233)) (define (A011629 n) (legendre-symbol n 239)) (define (A011630 n) (legendre-symbol n 241)) (define (A011631 n) (legendre-symbol n 251)) (define (A165471 n) (legendre-symbol n 65537)) ;; A019434(4)=65537. (define A165472 (PARTIALSUMS 0 0 A165471)) (define A165473 (ZERO-POS 0 0 A165472)) ;; (A165473 610) = 65536 ;; (A165473 611) = 65537 ;; (A165473 612) = 65543 (define A165474 (RECORD-ABSVALS-BETWEEN-ZEROS-POS 0 A165472 A165473)) (define (A165475 n) (A165472 (A165474 n))) (define (1+halved n) (floor->exact (/ (1+ n) 2))) ;; Like A165471, but instead of values -1 and +1, we have 0 and 1, ;; with the zeros in original A165471(65537*k) discarded, ;; so that this one (A179416) is a period 65536 sequence ;; instead of period 65537 as A165471 is: (define (A179416 n) (1+halved (A165471 (1+ (modulo n 65536))))) (definec (A179417 n) (let ((ul (A005408 n))) (let loop ((i (A000290 n)) (j 0) (s 0) ) (cond ((= j ul) s) ((= 0 (1+halved (A165471 (1+ i)))) (loop (1+ i) (1+ j) s)) (else (loop (1+ i) (1+ j) (+ s (expt 2 j)))) ) ) ) ) (definec (A179417wrong_after_255 n) (let ((ul (A005408 n))) (let loop ((i (A000290 n)) (j 0) (s 0) ) (cond ((= j ul) s) ((= 0 (A179416 i)) (loop (1+ i) (1+ j) s)) (else (loop (1+ i) (1+ j) (+ s (expt 2 j)))) ) ) ) ) (define (A179418 n) (A000120 (A179417 n))) ;; Note: (apply + (map A179418 (iota0 255))) = 32768 (define (A165476 n) (legendre-symbol n 131071)) ;; A000668(6)=131071. (define A165477 (PARTIALSUMS 0 0 A165476)) (define (A165478 n) (+ (* (floor->exact (/ n 2)) 131071) (* (modulo n 2) 131070))) ;; 0,131070,131071,262141,262142, (define A165478v2 (ZERO-POS 0 0 A165477)) ;; (map A165478 (iota0 4)) = (0 131070 131071 262141 262142) (define (A165479 n) (+ (* (floor->exact (/ n 2)) 131071) (* (+ 1 (* 2 (modulo n 2))) 43690))) (define A165479v2 (RECORD-ABSVALS-BETWEEN-ZEROS-POS 0 A165477 A165478)) ;; Not this: (define (A165480 n) (A165477 (A165479 n))) ;; 570,0,570,0,570,0,570,0,... (define A165480 (ZERO-POS 0 0 A163897)) ;; (A000045 23) = 28657 (define (A165481 n) (legendre-symbol n 28657)) (define A165482 (PARTIALSUMS 0 0 A165481)) (define A165483 (ZERO-POS 0 0 A165482)) ;; (A165483 232) = 28656 ;; (A165483 233) = 28657 ;; (A165483 234) = 28679 (define A165484 (RECORD-ABSVALS-BETWEEN-ZEROS-POS 0 A165482 A165483)) (define (A165485 n) (A165482 (A165484 n))) (define (A165486 n) (* (sgn (A165472 n)) (A000290 (A165472 n)))) (define (A165487 n) (* (sgn (A165477 n)) (A000290 (A165477 n)))) (define (A165488 n) (* (sgn (A165482 n)) (A000290 (A165482 n)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Here are the 30 A-numbers you requested: A165569 --- A165598. ;; Here are the 10 A-numbers you requested: A165599 --- A165608. ;; for n=1, a(n)=1, and for n>1, return first such i>a(n-1) that ;; abs(*Phi* - A108539(i)/A000040(i)) ;; < abs(*Phi* - A108539(a(n-1))/A000040(a(n-1))) ;; ;; The indexing sequence for "Successively Better Golden Semiprimes." (definec (A165569 n) (if (= 1 n) 1 (let* ((i (A165569 (-1+ n))) (champion (abs (- *Phi* (/ (A108539 i) (A000040 i))))) ) (let loop ((i (1+ i))) (cond ((< (abs (- *Phi* (/ (A108539 i) (A000040 i)))) champion) i ;; Found a better specimen than the current champion. ) (else (loop (1+ i))) ) ) ) ) ) (define (A165570 n) (* (A165571 n) (A165572 n))) ;; Cf. A108540 (define (A165571 n) (A000040 (A165569 n))) ;; Cf. A108541 (define (A165572 n) (A108539 (A165569 n))) ;; Cf. A108542 (define (A165573 n) (legendre-symbol n 257)) (define (A165574 n) (legendre-symbol n 263)) (define A165575 (PARTIALSUMS 0 0 A165573)) (define A165576 (PARTIALSUMS 0 0 A165574)) (define A165577 (PARTIALSUMS 0 0 A011626)) (define A165578 (PARTIALSUMS 0 0 A011627)) (define A165579 (PARTIALSUMS 0 0 A011628)) (define (A165581 n) (legendre-symbol n 524287)) ;; = A000668(7)=524287. (define A165582 (PARTIALSUMS 0 0 A165581)) (define A165583 (ZERO-POS 0 0 A165582)) (define A165584 (RECORD-ABSVALS-BETWEEN-ZEROS-POS 0 A165582 A165583)) (define (A165585 n) (A165582 (A165584 n))) (define (A165586 n) (legendre-symbol n 514229)) ;; = A005478(9) = A000045(29) (define A165587 (PARTIALSUMS 0 0 A165586)) (define A165588 (ZERO-POS 0 0 A165587)) (define A165589 (RECORD-ABSVALS-BETWEEN-ZEROS-POS 0 A165587 A165588)) (define (A165590 n) (A165587 (A165589 n))) (define (A165591 n) (jacobi-symbol n 59701)) ;; = A005385(11)*A005385(12) = 227*263. (define (A165591v2 n) (* (A011626 n) (A165574 n))) (define A165592 (PARTIALSUMS 0 0 A165591)) (define A165593 (ZERO-POS 0 0 A165592)) (define A165594 (RECORD-ABSVALS-BETWEEN-ZEROS-POS 0 A165592 A165593)) (define (A165595 n) (A165592 (A165594 n))) (define (A165596 n) (jacobi-symbol n 59881)) ;; = A005478(6)*A019434(3) = 233*257 = A117879(11). (define (A165596v2 n) (* (A011628 n) (A165573 n))) (define A165597 (PARTIALSUMS 0 0 A165596)) (define A165598 (ZERO-POS 0 0 A165597)) (define A165599 (RECORD-ABSVALS-BETWEEN-ZEROS-POS 0 A165597 A165598)) (define (A165600 n) (A165597 (A165599 n))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Hilbert curve in a square array, zero-based (define (A163357 n) (A163355 (A054238 n))) ;; Inverse: (define (A163358 n) (A054239 (A163356 n))) ;; Hilbert curve in a square array, transposed, zero-based (define (A163359 n) (A163357 (A061579 n))) ;; Inverse: (define (A163360 n) (A061579 (A163358 n))) ;; Hilbert curve in a square array, one-based (define (A163361 n) (1+ (A163357 (-1+ n)))) ;; Inverse: (define (A163362 n) (1+ (A163358 (-1+ n)))) ;; Hilbert curve in a square array, transposed, one-based (define (A163363 n) (1+ (A163359 (-1+ n)))) ;; Inverse: (define (A163364 n) (1+ (A163360 (-1+ n)))) (define A163365 (ROWSUMS0 A163357)) (define A163365v2 (ROWSUMS0 A163359)) ;; Here are the 10 A-numbers you requested: A163477 --- A163486. (define (A163477 n) (/ (A163365 n) 4)) (define (A163478 n) (/ (A163242 n) 3)) (define (A163479 n) (/ (A163342 n) 6)) (define (A163480 n) (A163334 (A000217 n))) (define (A163481 n) (A163334 (-1+ (A000217 (1+ n))))) (define (A163482 n) (A163357 (A000217 n))) (define (A163483 n) (A163357 (-1+ (A000217 (1+ n))))) ;; Cf. A163355 (defineperm1 (A163485 n) (let* ((i (floor->exact (/ (A000523 n) 2))) (dd (modulo (floor->exact (/ n (expt 4 i))) 4)) (r (if (zero? n) n (modulo n (expt 4 i)))) ) (cond ((zero? n) n) ((= 0 dd) ;; 00xy --> 00xy (A163485 r) ) ((= 1 dd) ;; 01xy --> 11c(y)x (+ (* 3 (expt 4 i)) (- (expt 4 i) 1 (A163485 (complement-i-oddpos-lsbs (A057300 r) i))) ) ) ((= 2 dd) ;; 10xy --> 01c(y)x (+ (expt 4 i) (- (expt 4 i) 1 (A163485 (complement-i-oddpos-lsbs (A057300 r) i))) ) ) (else ;; 11xy --> 10xy (+ (* 2 (expt 4 i)) (A163485 r)) ) ) ) ) ;; Oh I'm so lazy now! Can't bother now to find the formula for the inverse. ;; We can do this with defineperm1 because A163485(0) = 0. (define (A163486 n) (A163485 (- n))) (define (A147995 n) (A163485 (A054238 (A061579 n)))) (define A163484 (ROWSUMS0 A147995)) ;; Inverse of A147995 (define (A163544 n) (A061579 (A163546 n))) ;; Transpose of A147995: (define (A163545 n) (A163485 (A054238 n))) (define (A163546 n) (A054239 (A163486 n))) ;; ----------------------------------------------------------------- ;; Here are the 20 A-numbers you requested: A163528 --- A163547. (define (A163528 n) (A025581 (A163335 n))) (define (A163528v2 n) (A002262 (A163337 n))) (define (A163528v3 n) (A163325 (A163332 n))) (define (A163529 n) (A002262 (A163335 n))) (define (A163529v2 n) (A025581 (A163337 n))) (define (A163529v3 n) (A163326 (A163332 n))) (define (A163530 n) (+ (A163528 n) (A163529 n))) (define (A163531 n) (+ (A000290 (A163528 n)) (A000290 (A163529 n)))) (define (A163532 n) (if (zero? n) n (- (A163528 n) (A163528 (- n 1))))) (define (A163533 n) (if (zero? n) n (- (A163529 n) (A163529 (- n 1))))) ;; a(n) = (A163534 A008591) ;; * 9 n (define (A163534 n) ;; One-based. (modulo (+ 3 (A163532 n) (A163533 n) (abs (A163533 n))) 4) ) (define (A163534origdork n) ;; One-based. (+ (modulo (+ 3 (A163532 n) (A163533 n)) 4) (abs (A163533 n))) ) (define (A163535 n) ;; One-based. (modulo (+ 3 (A163532 n) (A163533 n) (abs (A163532 n))) 4) ) ;; Also one-based sequences: ;; (same-intfuns? (compose-funs A163536 A008591) (compose-funs A163536 A008591 A008591) 59049) --> #t (define (A163536 n) (A163241 (modulo (- (A163534 (1+ n)) (A163534 n)) 4))) (define (A163537 n) (A163241 (modulo (- (A163535 (1+ n)) (A163535 n)) 4))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; This should sort A163344 into ascending order, ;; which seems to be ;; A037314 Numbers n such that (sum of base 3 digits of n)=(sum of base 9 digits of n). ;; ;; Similarly, A163343(n)+1 (submit!) gives the central diagonal of ;; A163338/A163340, and when it is sorted, there are ;; both primes and squares in it. ;; Also A062880(n)+1 contains primes (is this A145812 ?) ;; Yes, comment a(n)=2*A000695(n-1)+1 [From Vladimir Shevelev (shevelev(AT)bgu.ac.il), Nov 07 2008] (define (A128173 n) ;; Numbers in ternary Gray code order. n ;; Not ready. Read Zunic's paper. ) ;; Here are the 20 A-numbers you requested: A166404 --- A166423. ;; Here are the 20 A-numbers you requested: A166424 --- A166443. ;; Do something to the starting offsets, e.g. change A163534 and A163540 ;; to begin with offset 0? (In which case we define (PARTIALSUMS 1 0 ...) ? ;; One-based: (define (A166436 n) (A102283 (A163536 n))) ;; Semantics: gives the number of quarter-turns the Hilbert walk traveler ;; has done with regards to the starting (default) direction, ;; since last "wounding back". (There exists a term for this, ;; something like a "winding number" or such.) ;; Compute up to some good value of A166434: (define A166437 (PARTIALSUMS 2 1 A166436)) ;; Note how this differs from "partial sums modulo 4", which gives the absolute direction: (definec (A163534v2 n) (if (= 1 n) 0 (A010873 (+ (A163534v2 (-1+ n)) (A166436 (-1+ n)))))) ;; A163534(n) = A010873(A166437(n)) (define A166434 (ZERO-POS 1 1 A166437)) ;; Begins as: 1,3,4,39,40,363,364,3279,3280,... ;; (take also bisections). (define A166435 (RECORD-POS 1 1 A166437)) ;;;;;;;;;;;;;;;;;;;;; ;; Sum of the winding numbers: ;; (Is it the same as partial sums of sums of relative directions? Of course. ;; Which one is better. Consider also negatives of the other.) (define (A166439 n) (+ (A166437 n) (A166443 n))) (define A166438 (ZERO-POS 1 1 A166439)) (define (A166442 n) (A102283 (A163542 n))) (define A166443 (PARTIALSUMS 2 1 A166442)) (define A166440 (ZERO-POS 1 1 A166443)) ;; Begins as: 1,2,3,29,51,461,819,7373,13107, (define A166441 (RECORD-POS 1 1 A166443)) ;; Note how this differs from "partial sums modulo 4", which gives the absolute direction: (definec (A163540v2 n) (if (= 1 n) 0 (A010873 (+ (A163540v2 (-1+ n)) (A166442 (-1+ n)))))) ;; A163540(n) = A010873(A166443(n)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; --- ;; These already given by Claude Lenormand: (define (A059253 n) (A025581 (A163358 n))) (define (A059253v2 n) (A002262 (A163360 n))) (define (A059253v3 n) (A059905 (A163356 n))) (define (A059252 n) (A002262 (A163358 n))) (define (A059252v2 n) (A025581 (A163360 n))) (define (A059252v3 n) (A059906 (A163356 n))) (define (A059261 n) (+ (A059252 n) (A059253 n))) (define (A059285 n) (- (A059253 n) (A059252 n))) (define (A163538 n) (if (zero? n) n (- (A059253 n) (A059253 (- n 1))))) (define (A163539 n) (if (zero? n) n (- (A059252 n) (A059252 (- n 1))))) ;; a(n) = (A163534 A008598) ;; * 16 n (define (A163540 n) ;; One-based. (modulo (+ 3 (A163538 n) (A163539 n) (abs (A163539 n))) 4) ) (define (A163540origdork n) ;; One-based. (+ (modulo (+ 3 (A163538 n) (A163539 n)) 4) (abs (A163539 n))) ) (define (A163541 n) ;; One-based. (modulo (+ 3 (A163538 n) (A163539 n) (abs (A163538 n))) 4) ) ;; (same-intfuns? (compose-funs A163542 A008598) (compose-funs A163542 A008598 A008598) (expt 2 16)) --> #t ;; Also one-based sequences: (define (A163542 n) (A163241 (modulo (- (A163540 (1+ n)) (A163540 n)) 4))) (define (A163543 n) (A163241 (modulo (- (A163541 (1+ n)) (A163541 n)) 4))) (define (A163547 n) (+ (A000290 (A059252 n)) (A000290 (A059253 n)))) ;; Here are the 20 A-numbers you requested: A163528 --- A163547. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (A072661 n) (A059905 (A048679 n))) (define (A072662 n) (A059906 (A048679 n))) (define (packA054238 x y) (+ (A000695 x) (* 2 (A000695 y)))) (define (packA054238tr x y) (+ (A000695 y) (* 2 (A000695 x)))) ;; Old version: (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1))))) ;; This new one returns the exponent k, such that 2^k = n, in case n is ;; the power of 2, otherwise #f. (define (pow2?v2 n) (and (> n 0) (zero? (A004198bi n (- n 1))) (A000523 n))) (define (pow2? n) (let loop ((n n) (i 0)) (cond ((zero? n) #f) ((odd? n) (and (= 1 n) i)) (else (loop (/ n 2) (1+ i))) ) ) ) ;; "Binary asymmetry index", 0 if n is a binary palindrome, i.e. in A006995. (define (A037888 n) (/ (A000120 (A003987bi n (A030101 n))) 2)) (define (A004442 n) (A003987bi n 1)) ;; Natural numbers, pairs reversed: a(n) = n + (-1)^n; n XOR 1. (define (A003188 n) (A003987bi n (floor->exact (/ n 2)))) ;; Gray Code. ;; Prove! (Defined with the help A054429 in analogous manner ;; as A122199 is defined as a "recursed variant" of A122155.) (define (A003188v2 n) (if (< n 1) n (let ((m (A054429 n))) (+ (A053644 m) (A003188v2 (A053645 m)))))) ;; Inverse then follows as: (define (A006068 n) (if (< n 1) n (A054429 (+ (A053644 n) (A006068 (A053645 n)))))) ;; Using the formula given by Benoit Cloitre: ;; a(0)=0, a(3k)=1-a(k); a(3k+1)=a(3k+2)=1. (definec (A014578 n) (cond ((zero? n) n) ((zero? (modulo n 3)) (- 1 (A014578 (/ n 3)))) (else 1) ) ) ;; Fix 0; exchange even and odd numbers. (define (A014681 n) (if (zero? n) 0 (+ n (- (* 2 (modulo n 2)) 1)))) (define (A048735 n) (A004198bi n (>> n 1))) (define (A014081 n) (A000120 (A048735 n))) (define (packA048680oA054238 x y) (A048680 (packA054238 x y))) (define (packA048680oA054238tr x y) (A048680 (packA054238tr x y))) (define (A072793 n) (A048680 (A054238 n))) ;; EIS # reserved for packA048680oA054238 (define (A072794 n) (A054239 (A048679 n))) ;; inverse for above. ;; A072732 - A072741 reserved for us. (define (A072732 n) (packA072732 (A025581 n) (A002262 n))) (define (packA072732 x y) (let ((x-y (- x y))) (cond ((<= x-y 0) ;; i.e. (x <= y) (packA001477 (+ (* 2 x) (modulo x-y 2)) (+ (* 2 x) (floor->exact (/ (1+ (- x-y)) 2))) ) ) ;; ((< x-y 2) ;; either x=y, or x=y+1. ;; (packA001477 (+ (* 2 y) x-y) (* 2 y)) ;; ) (else ;; x > y. (floor->exact (/ -1 2)) has to be -1 !!! (packA001477 (+ (* 2 (1+ y)) (floor->exact (/ (- x-y 2) 2))) (+ (* 2 y) (modulo (1+ x-y) 2)) ) ) ) ) ) (define (A072733 n) (packA072733 (A025581 n) (A002262 n))) (define (packA072733 x y) (cond ((<= x y) ;; i.e. (x <= y) (let ((half-x (floor->exact (/ x 2)))) (packA001477 half-x (+ half-x (* 2 (- y (* 2 half-x) (modulo x 2))) (modulo x 2) ) ) ) ) (else ;; x > y (let ((half-y (floor->exact (/ y 2)))) (packA001477 (+ 1 half-y (* 2 (- (-1+ x) (* 2 half-y) (modulo y 2))) (modulo y 2) ) half-y ) ) ) ) ) (define (A072734 n) (packA072734 (A025581 n) (A002262 n))) ;; And code this as an inverse of A072735 (the next one)... ;; Using this as a NxN->N packing bijection for a global arithmetic ;; unranking function for Catalan structures gives a better result ;; than A072642: ;; (define weird1tr (max-n-fun-with-arithrank-scheme packA072734)) ;; (map binwidth (map weird1tr (iota0 10))) ;; (0 1 2 4 6 8 13 23 43 82 160) ;; And using it's "4th power" gives even better results in a certain range: ;; (0 1 2 8 9 11 15 23 39 71 134) ;; (define (packA072734 x y) (let ((x-y (- x y))) (cond ((negative? x-y) ;; i.e. (y > x) (packA001477 (+ (* 2 x) (modulo (1+ x-y) 2)) (+ (* 2 x) (floor->exact (/ (+ (- x-y) (modulo x-y 2)) 2))) ) ) ((< x-y 3) ;; i.e. (x >= y and x <= y+2) (packA001477 (+ (* 2 y) x-y) (* 2 y)) ) (else ;; x >= y+3 (packA001477 (+ (* 2 y) (floor->exact (/ (1+ x-y) 2)) (modulo (1+ x-y) 2)) (+ (* 2 y) (modulo x-y 2)) ) ) ) ) ) (define (A072735 n) (packA072735 (A025581 n) (A002262 n))) (define (packA072735 x y) (cond ((<= x y) ;; i.e. (x <= y) (let ((half-x (floor->exact (/ x 2)))) (packA001477 half-x (+ half-x (* 2 (- y (* 2 half-x))) (modulo x 2) (if (and (eq? x y) (even? x)) 0 -1) ) ) ) ) (else ;; x > y (let ((half-y (floor->exact (/ y 2)))) (packA001477 (+ half-y (* 2 (- (-1+ x) (* 2 half-y))) (modulo y 2) (if (and (eq? x (1+ y)) (even? y)) 1 0) ) half-y ) ) ) ) ) (define (A072736 n) (A025581 (A072733 n))) ;; X-projection of A072732 (define (A072737 n) (A002262 (A072733 n))) ;; Y-projection of A072732 (define (A072738 n) (A025581 (A072732 n))) ;; X-projection of A072733 (define (A072739 n) (A002262 (A072732 n))) ;; Y-projection of A072733 (define (A072740 n) (A025581 (A072735 n))) ;; X-projection of A072734 (define (A072741 n) (A002262 (A072735 n))) ;; Y-projection of A072734 ;; Also A072781 - A072800 reserved for us. (define (A072781 n) (A025581 (A072734 n))) ;; X-projection of A072735 (define (A072782 n) (A002262 (A072734 n))) ;; Y-projection of A072735 (define (A072783 n) (- (A072740 n) (A072736 n))) (define (A072784 n) (- (A072741 n) (A072737 n))) (define (A072785 n) (- (A072781 n) (A072738 n))) (define (A072786 n) (- (A072782 n) (A072739 n))) (define (A075300bi x y) (-1+ (* (expt 2 x) (1+ (* 2 y))))) (define (A075300 n) (A075300bi (A025581 n) (A002262 n))) (define (A075302bi x y) (-1+ (* (1+ (* 2 x)) (expt 2 y)))) (define (A075302 n) (A075302bi (A025581 n) (A002262 n))) ;; (map binexp->runcount1list (iota0 16)) ;; --> (() (1) (1 1) (2) (1 2) (1 1 1) (2 1) (3) (1 3) ;; (1 2 1) (1 1 1 1) (1 1 2) (2 2) (2 1 1) (3 1) (4) (1 4)) (define (binexp->runcount1list n) ;; (length (binexp->runcount1list n)) gives A005811 (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 0) (prev-bit (modulo n 2))) (if (zero? n) (cons count rc) (if (eq? (modulo n 2) prev-bit) ;; If the lsb has not changed (loop (floor->exact (/ n 2)) rc (1+ count) (modulo n 2) ) (loop (floor->exact (/ n 2)) ;; If it has changed (cons count rc) 1 (modulo n 2) ) ) ) ) ) ) (define (runcount1list->binexp lista) (let loop ((lista lista) (s 0) (state 1)) (cond ((null? lista) s) (else (loop (cdr lista) (+ (* s (expt 2 (car lista))) (* state (- (expt 2 (car lista)) 1)) ) (- 1 state) ) ) ) ) ) ;; For each 0 in lista we generate a single 0 in binary expansion, ;; and for each non-zero natural number n, we generate n 1's followed ;; by one 0. (define (n-tuple->bittuple lista) (let loop ((lista lista) (s 0)) (cond ((null? lista) s) (else (loop (cdr lista) (+ (* (expt 2 (+ 1 (car lista))) s) (* 2 (- (expt 2 (car lista)) 1)) ) ) ) ) ) ) ;; ;; Replace in the binary expansion of n each 1-bit ;; with the distance to the next 1-bit: ;; ;; (binexp->siteswap-list 5) --> (2 0 1) ;; (binexp->siteswap-list 6) --> (1 2 0) ;; (binexp->siteswap-list 7) --> (1 1 1) ;; (binexp->siteswap-list 8) --> (4 0 0 0) ;; (binexp->siteswap-list 9) --> (3 0 0 1) ;; (binexp->siteswap-list 10) --> (2 0 2 0) (define (binexp->siteswap-list n) (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 1)) (if (zero? n) rc (if (zero? (modulo n 2)) (loop (/ n 2) (cons 0 rc) (1+ count) ) (loop (floor->exact (/ n 2)) (cons count rc) 1 ) ) ) ) ) ) ;; Pierre Lamothe, Fri, 21 May 2004: (definec (A116623 n) ;; C.f. A001047(n) = A116623(A000225(n)) (cond ((zero? n) 1) ((even? n) (+ (A116623 (/ n 2)) (expt 2 (A000523 n)))) (else (+ (* 3 (A116623 (/ (- n 1) 2))) (expt 2 (+ 1 (A000523 n))))) ) ) (define (A116640 n) (A116623 (A059893 n))) ;; (define seqA116641 (list-head (uniq (sort (map A116623 (iota0 512)) <)) 162)) (define (A116641 n) (list-ref seqA116641 n)) (define (A116642 n) (A007088 (A116641 n))) ;; A055941 a(n) = sum(i[j]-j, j = 0..k-1) where n = sum( 2^i[j], j = 0 .. k-1). ;; As I interpret it: vector i gives the positions of 1-bits in n, ;; and we take (positions 0-based from the least significant end): ;; Sum (position of each 1-bit - how manyth 1-bit it is from the right ;; (first = 0, second = 1, etc.) ;; over all 1-bits of n. ;; ;; This is equivalent of taking ;; Sum (total number of zero-bits to the right of 1-bit) ;; over all 1-bits of n. (define (A055941 n) (let loop ((n n) (ze 0) (s 0)) ;; ze = zeros encountered, s = sum. (cond ((zero? n) s) ((even? n) (loop (/ n 2) (1+ ze) s)) (else (loop (/ (-1+ n) 2) ze (+ s ze))) ) ) ) ;; A161511 Number of 1...0 pairs in binary representation of 2n. ;; a(2n) = a(n) + A000120(n); a(2n+1) = a(n) + 1. ;; Note that A161511(n) = A055941(n)+A000120(n). (define (A161511 n) (let loop ((n n) (ze 0) (s 0)) ;; ze = zeros encountered, s = sum. (cond ((zero? n) s) ((even? n) (loop (/ n 2) (1+ ze) s)) (else (loop (/ (-1+ n) 2) ze (+ s (1+ ze)))) ) ) ) ;; Square array A126441: (Alford Arnold) ;; a(n) occurs in the row A053645(n). ;; Each non-zero m occurs in row A053645(m) and column A161511(m). ;; (both zero-based.) ;; For each row r, the first non-zero term is A004760(r+1). ;; The least possible starting column for the row on which a(n) ;; is, is A000523(n+1). ;; The second value on each row is A004760(n+1) plus A062383(n); ;; subsequent values increase by ever enlarging powers of two. ;; (define (A126441 n) (A126441onebased (1+ n))) (definec (A126441onebased n) (cond ((< n 2) n) (else (let ((prev (A126441onebased (- n (/ (A053644 n) 2))))) (if (or (= (A053644 n) (* 2 (A053644 (A053645 n)))) ;; n in A004755? (zero? prev) ;; Row hasn't started yet? ) (let ((starter (A004760 (1+ (A053645 n))))) (if (> (A161511 starter) (1+ (A000523 n))) 0 starter ) ) (A004754 prev) ) ) ) ) ) (define (A161920 n) (A161511 (A004760 n))) ;; Offset 1. (define A166274 (NONZERO-POS 1 0 A126441)) (define A166275 (ZERO-POS 1 0 A126441)) (defineperm1 (A161924 n) (A126441 (A166274 n))) (define (A166276 n) (A161924 (- n))) ;; upto 87. ;; A000070, off 0, starts as: 1,2,4,7,12,19,30,45,67,97,139,195,272, ;; A026905, off 1, starts as: 1,3,6,11,18,29,44,66,96,138,194,271, (define seqA000070 '(1 2 4 7 12 19 30 45 67 97 139 195 272 373 508 684 915 1212 1597 2087 2714 3506 4508 5763 7338 9296 11732 14742 18460 23025 28629 35471 43820 53963 66273 81156 99133 120770 146785 177970 215308 259891 313065 376326 451501) ) (define seqA026905 '(#f 1 3 6 11 18 29 44 66 96 138 194 271 372 507 683 914 1211 1596 2086 2713 3505 4507 5762 7337 9295 11731 14741 18459 23024 28628 35470 43819 53962 66272 81155 99132 120769 146784 177969 215307) ) (define (A000070 n) (list-ref seqA000070 n)) ;; Lazy now! (define (A026905 n) (list-ref seqA026905 n)) ;; Sequence A161919: sort each subsequence A161924(A000070(k-1)..A026905(k)) ;; into ascending order. ;; (define seqA161924 (cons #f (map A161924 (iota (A026905 19))))) ;; (define seqA161919 (cons #f (append-map! (lambda (n) (sort (sublist seqA161924 (A000070 (-1+ n)) (1+ (A026905 n))) <)) (iota 19)))) (defineperm1 (A161919 n) (list-ref seqA161919 n)) ;; Lazy now! (define (A166277 n) (A161919 (- n))) (definec (A001477hardway n) ;; Compressed version of A126441. (cond ((< n 2) n) ;; n+1 in A004755? ((= (A053644 n) (* 2 (A053644 (A053645 n)))) (A004760 (1+ (A053645 n))) ) (else ;; Otherwise, the previous term of the row + msb of that term. (A004754 (A001477hardway (- n (/ (A053644 n) 2)))) ) ) ) ;; Here are the 6 A-numbers you requested: A116623 --- A116628. ;; From Paul D. Hanna Feb 19 2006: ;; Set a(1)=1; for n>1, a(n) = least positive integer not appearing earlier ;; such that ;; {a(k)|1= (1 2 3 4 7 11 26 42 109 166 373 772 1532) ;; (map A116624 (map A116628 (iota 13))) --> (1 2 4 8 16 32 64 128 256 512 1024 2048 4096) ;; A116624(1) = 1; A116624(n) = the least positive integer i distinct from any of A116624(1..n-1) ;; and A116625(1..n-2), such that ;; also (i XOR A116624(n-1)) is not present in A116625(1..n-2) nor in A116624(1..n-1) ;; (Note that (i XOR A116624(n-1)) cannot be A116624(n-1), because i > 0) ;; Are any of these conditions superfluous? (definec (A116624old n) (cond ((= 1 n) 1) (else (let outloop ((i 1)) ;; Play sure, and start always from the beginning, i is our candidate. (let ((k (A003987bi i (A116624old (- n 1))))) ;; Candidate for A116625(n-1) (let inloop ((j (- n 1))) ;; We compare i and k to all A116624old(n-1 .. 1) and A116625(n-1 .. 1) (cond ((zero? j) i) ;; No clashes found, 'i' is the man we were looking for! ((= i (A116624old j)) (outloop (+ i 1))) ;; A116624 wouldn't be distinct, try next. ((= i (A116625old (- j 1))) (outloop (+ i 1))) ;; A116624 wouldn't be disjoint from A116625 ((= k (A116625old (- j 1))) (outloop (+ i 1))) ;; A116625 wouldn't be distinct, try next. ((= k (A116624old j)) (outloop (+ i 1))) ;; A116625 wouldn't be disjoint from A116624 (else (inloop (- j 1))) ;; So far so good, check also smaller terms of A116624 & -25. ) ) ) ) ) ) ) (define (A116625old n) (if (zero? n) n (A003987bi (A116624old n) (A116624old (+ n 1))))) (definec (A116626old n) (if (odd? n) (A116624old (/ (+ n 1) 2)) (A116625old (/ n 2)))) (definec (A116627old n) (first-n-where-fun_n-is-i1 A116626old n)) (define (A116624 n) (A116626 (- (* 2 n) 1))) (define (A116625 n) (A116626 (* 2 n))) ;; If n is odd, then A116626(n) = A116626(n-1) XOR A116626(n-2). ;; if n is even, then find the first i >= A116648(n-1) ;; such that neither i nor (i XOR A116626(n-1)) is present in A116626(1..n-1), ;; and return (i XOR A116626(n-1)). (What if we return i instead?) (defineperm1 (A116626 n) (cond ((= 1 n) 1) ((odd? n) (A003987bi (A116626 (-1+ n)) (A116626 (- n 2)))) (else (let outloop ((i (A116648 (-1+ n)))) (let ((k (A003987bi i (A116626 (-1+ n))))) (let inloop ((j (- n 1))) ;; We compare i and k to all A116626(n-1 .. 1) (cond ((zero? j) k) ;; No clashes found, 'k' is the man we were looking for! ((= i (A116626 j)) (outloop (+ i 1))) ((= k (A116626 j)) (outloop (+ i 1))) (else (inloop (- j 1))) ;; So far so good check also against smaller terms of A116626. ) ) ) ) ) ) ) (define (A116627 n) (A116626 (- n))) ;; Take values from invcache. Must be computed after A116626. (define A116628 (fun-succ-matching-is0 (lambda (i) (pow2? (A116624 i))))) ;; We consider a > b (i.e. not less than b) also in case a is nil. ;; (Because the stateful caching system used by defineperm1.) (define (not-lte? a b) (cond ((not (number? a)) #t) (else (> a b)))) ;; Here are the 4 A-numbers you requested: A116648 --- A116651. ;; (map A116648 (iota 128)) ;; (2,2,4,4,5,5,5,5,7,7,7,7,7,7,9,9,11,11,11,11,11,11,18,18,19,19,19,19,20,20,20,20,21,21,21,21,21,21,21,21,27,27,27,27,27,27,27,27,29,29,29,29,30,30,30,30,30,30,30,30,30,30,39,39,39,39,42,42,42,42,44,44,44,44,45,45,45,45,46,46,46,46,46,46,47,47,47,47,71,71,71,71,71,71,73,73,73,73,74,74,74,74,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76) ;; (map A116649 (iota 32)) ;; (1 3 5 9 15 17 23 25 29 33 41 49 53 63 67 71 75 79 85 89 95 99 103 107 139 143 163 167 175 179 199 219) ;; (map A116650 (iota 32)) ;; (2 4 5 7 9 11 18 19 20 21 27 29 30 39 42 44 45 46 47 71 73 74 75 76 78 83 87 88 90 109 113 116) ;; (map A116651 (iota0 5)) ;; (2 2 4 5 9 20) (definec (A116648 n) (if (< n 2) (+ n 1) ;; A116626 begins as 1,3,2,6,4,12,8,13,5,15,... (let ((prev (A116648 (- n 1)))) (cond ((not (= (A116626 n) prev)) prev) (else (let loop ((i (+ 1 prev))) (cond ((not-lte? (A116627 i) n) i) (else (loop (+ 1 i))) ) ) ) ) ) ) ) (define A116649 (fun-succ-matching-is0 (lambda (i) (not (= (A116648 (- i 1)) (A116648 i)))))) (define (A116650 n) (A116648 (A116649 n))) (define (A116651 n) (A116648 (A000079 n))) ;; The first differences of A005228: ;; (define (A030124 n) (cond ((= n 0) 2) ((= n 1) 4) (else (- (A005228 (+ n 2)) (A005228 (+ n 1)))))) ;; Hofstadter's A005228 = 1,3,7,12,18,26,35,45,56,69,83,98,114,131,150,170,191,213,236,260,... (starting offset = 1). ;; A030124+ 2,4,5,6,8,9,10,11,13,14,15,16,17,19,20,... ;; A000027 1,2,3,4,5,6,7,8,9 ;; pseuinv 0,1,1,2,3,4,4,5,... ;; (define A005228 (COMPLEMENT 1 (compose-funs A030124 -1+))) ;; Needs one-based seq. ;; Hofstadter's A005228 = 1,3,7,12,18,26,35,45,56,69,83,98,114,131,150,170,191,213,236,260,... ;; A030124+ 2,4,5,6,8,9,10,11,13,14,15,16,17,19,20,... ;; A000027 1,2,3,4,5,6,7,8,9 ;; Defined as the partial sums of A030124+ ;; Note that to kick start this recursion, we need to specify the three initial values explicitly: (definec (A005228 n) (cond ((= n 1) 1) ((= n 2) 3) ((= n 3) 7) (else (+ (A005228 (- n 1)) (A030124+ (- n 1)))))) (define A030124+ (COMPLEMENT 1 A005228)) ;; One-based. (define A030124 (compose-funs A030124+ 1+)) ;; Zero-based. ;; Few Murthyisms: ;; %S A096111 1,2,2,3,3,6,6,4,4,8,8,12,12,24,24,5,5,10,10,15,15,30,30,20,20,40,40,60, ;; %T A096111 60,120,120,6,6,12,12,18,18,36,36,24,24,48,48,72,72,144,144,30,30,60,60, ;; %U A096111 90,90 ;; Zero-based. (definec (A096111 n) (cond ;; ((zero? n) 1) ((pow2? (+ n 1)) (+ 2 (A000523 n))) (else (* (+ 1 (A000523 n)) (A096111 (A053645 n)))) ) ) ;; Bisection of above (zero-based): (define (A121663v2 n) (A096111 (* 2 n))) ;; Zero-based. (definec (A121663 n) (cond ((zero? n) 1) ((pow2? n) (+ 2 (A000523 n))) (else (* (+ 2 (A000523 n)) (A121663 (A053645 n)))) ) ) ;; One-based, permutation of natural numbers: ;; v v v v ;; 1 2 3 4 5 6 7 8 9 0 1 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ;;%S A096114 1,2,3,5,4,6,10,11,9,8,7,12,19,20,21,23,22,18,16,17,15,14,13,24,37,38, ;;%T A096114 39,41,40,42,46,47,45,44,43,36,31,32,33,35,34,30,28,29,27,26,25,48 ;; C.f. A073080 (definec (A096114 n) (cond ((< n 3) n) ((and (zero? (modulo n 3)) (pow2? (/ n 3))) n) (else (let ((lastfix (* 3 (expt 2 (A000523 (floor->exact (/ n 3))))))) (+ lastfix (A096114 (- (* 2 lastfix) n))) ) ) ) ) ;; Inverse of the above. One-based. Seems to be formed in a simple way: ;; 1 2 3 5 4 6 11 10 9 7 8 12 23 22 21 19 20 18 13 14 15 17 16 24 ;; 47 46 45 43 44 42 37 38 39 41 40 36 25 26 27 29 28 30 35 34 33 31 32 48 (definec (A121664 n) (first-n-where-fun_n-is-i1 A096114 n)) ;; One-based. Could be zero-based as well. (definec (A096115 n) (cond ((pow2? (+ n 1)) (+ 1 (A000523 n))) ((pow2? n) (+ 1 (A096115 (- n 1)))) (else (* (+ (A000523 n) 1) (A096115 (A035327 (- n 1))))) ) ) ;; One-based. Could be zero-based as well. (definec (A096115v2 n) (cond ((pow2? (+ n 1)) (+ 1 (A000523 n))) ((pow2? n) (+ 1 (A096115v2 (- n 1)))) (else (* (+ (A000523 n) 1) (A096115v2 (- (expt 2 (A000523 (- n 1))) (A053645 (- n 1)) 1)))) ) ) ;; A122154 --- A122156. ;; (map (lambda (n) (count-the-occurrences A096115 n 1 (A000079 n))) (iota 16)) ;; --> (1 2 2 2 2 4 2 4 2 4 2 6 2 4 4 4) ;; halved --> Is it A045778, yes, it is! (define (A025147v2_slow n) (if (< n 2) n (count-the-occurrences A096116 n 1 (+ 1 (A000079 (- n 2)))))) (define (A045778v2_slow n) (count-the-occurrences A121663 n 0 (if (= 1 n) 0 (A000079 (- n 2))))) (define (A122155 n) (cond ((< n 1) n) ((pow2? n) n) (else (- (* 2 (A053644 n)) (A053645 n))) ) ) (definec (A122198 n) (if (< n 1) n (A122155 (+ (A053644 n) (A122198 (A053645 n)))) ) ) (definec (A122199 n) (if (< n 1) n (let ((m (A122155 n))) (+ (A053644 m) (A122199 (A053645 m))) ) ) ) (definec (A096116 n) (cond ((= 1 n) 1) ((pow2? (- n 1)) (+ 2 (A000523 (- n 1)))) (else (+ 2 (A000523 (- n 1)) (A096116 (+ 2 (A035327 (- n 1)))))) ) ) ;; One-based. There's opportunity for further cleaning of this formula: (Use A035327) (definec (A096116v2 n) (cond ((= 1 n) 1) ((pow2? (- n 1)) (+ 2 (A000523 (- n 1)))) (else (+ 2 (A000523 (- n 1)) (A096116v2 (+ 1 (- (expt 2 (A000523 (- n 1))) (A053645 (- n 1))))))) ) ) ;; ---------------------- ;; a(n)=a(n-1)+a(m), where m=2^(p+1)+2-n, and 2^p= 4. (definec (A050049 n) (cond ((= 1 n) 1) (else (+ (A050049 (- n 1)) (A050049 (+ 1 (A035327 (- n 2)))))) ) ) ;; Murthy has supplied A096118 as a duplicate of Kimberling's A050029: (definec (A050029 n) (cond ((< n 3) 1) (else (+ (A050029 (- n 1)) (A050029 (+ 1 (A035327 (- n 2)))))) ) ) ;; Zero-based: Compute up to n=14: (define (A096119 n) (A050029 (+ 1 (expt 2 n)))) ;; Murthy's A096120 is probably an erroneous duplicate of Kimberling's A050030 ! (definec (A050030 n) (cond ((< n 3) 1) (else (+ (A050030 (- n 1)) (A050030 (+ 1 (A053645 (- n 2)))))) ) ) (define (A105996 n) (A050030 (+ 1 (expt 2 n)))) (defineperm1 (A076105 n) (cond ((< n 2) n) ((zero? (A025581 (- n 1))) ;; n is triangular, on the trailing edge (let* ((rowindex (A002024 n)) (rowsumsofar (add A076105 (+ (A000217 (- rowindex 1)) 1) (- (A000217 rowindex) 1) ) ) (prevrowsum (A076103 (- rowindex 1))) ) (let loop ((i (modulo (- rowsumsofar) prevrowsum))) (if (and (not (zero? i)) (not-lte? (A122154 i) (- n 1))) i (loop (+ i prevrowsum)) ) ) ) ) (else (luuA076105 (- n 1))) ) ) (define (A076101 n) (A076105 (+ 1 (A000217 (- n 1))))) (define (A076102 n) (A076105 (A000217 n))) (define (A076103 n) (add A076105 (+ (A000217 (- n 1)) 1) (A000217 n))) (define (A076104 n) (/ (A076103 (+ n 1)) (A076103 n))) (define (A122154 n) (A076105 (- n))) ;; Take values from invcache. Must be computed after A076105 ;; luu stands for "least un-used". We don't want to submit these to OEIS, no inherent value! (definec (luuA076105 n) ;; Least natural number which does not occur in A076105(1..n). (if (< n 2) (+ n 1) ;; A094280 begins as 1,2,3,4,5,6,... (let ((prev (luuA076105 (- n 1)))) (cond ((not (= (A076105 n) prev)) prev) (else (let loop ((i (+ 1 prev))) (cond ((not-lte? (A122154 i) n) i) (else (loop (+ 1 i))) ) ) ) ) ) ) ) ;; 1,2,3,4,5,6,7,8,9,21,10,11,12,13,44,14,15,16,17,18,100,19,20,22,23,24, (defineperm1 (A094280 n) (cond ((< n 2) n) ((zero? (A025581 (- n 1))) ;; n is triangular, on the trailing edge (let* ((rowindex (A002024 n)) (rowsumsofar (add A094280 (+ (A000217 (- rowindex 1)) 1) (- (A000217 rowindex) 1) ) ) (prevrowsum (A094283 (- rowindex 1))) ) ;; (format #t "rowindex=~a, rowsumsofar=~a, prevrowsum=~a\n" ;; rowindex rowsumsofar prevrowsum ;; ) ;; There are more intelligent ways to do this: (... ;-) ;; (let loop ((i (luuA094280 (- n 1)))) ;; (if (and (> (+ rowsumsofar i) prevrowsum) ;; Differs from A076105. ;; (zero? (modulo (+ rowsumsofar i) prevrowsum)) ;; ) ;; i ;; (loop (+ i 1)) ;; ) ;; ) (let loop ((i (modulo (- rowsumsofar) prevrowsum))) (if (and (> (+ i rowsumsofar) prevrowsum) (not-lte? (A122156 i) (- n 1))) i (loop (+ i prevrowsum)) ) ) ) ) (else (luuA094280 (- n 1))) ) ) (define (A094281 n) (A094280 (+ 1 (A000217 (- n 1))))) (define (A094282 n) (A094280 (A000217 n))) (definec (A094283 n) (add A094280 (+ (A000217 (- n 1)) 1) (A000217 n))) (define (A094284 n) (/ (A094283 (+ n 1)) (A094283 n))) (define (A122156 n) (A094280 (- n))) ;; Take values from invcache. Must be computed after A094280 (definec (luuA094280 n) ;; Least natural number which does not occur in A094280(1..n). (if (< n 2) (+ n 1) ;; A094280 begins as 1,2,3,4,5,6,... (let ((prev (luuA094280 (- n 1)))) (cond ((not (= (A094280 n) prev)) prev) (else (let loop ((i (+ 1 prev))) (cond ((not-lte? (A122156 i) n) i) (else (loop (+ 1 i))) ) ) ) ) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CatTrianglDirect := (r,m) -> `if`((m < 0),0,((r-m+1)*(r+m)!)/(r! * m! * (r+1))); ;; A009766 gives also: ;; a(n,m) = C(n+m,n)*(n-m+1)/(n+1), n >= m >= 0. (define (A009766tr r m) (if (or (> m r) (< m 0)) 0 ;; Maybe we should raise an error instead?! (/ (* (1+ (- r m)) (! (+ r m))) (* (! r) (! m) (1+ r)) ) ) ) (define (A009766 n) (A009766tr (A003056 n) (A002262 n))) ;; ;; (definec (A0similarv2 n) (convolve (lambda (n) (if (zero? n) 1 (A000045 n))) A000108 n)) ;; ;; (definec (A0similarv3 n) ;; (if (zero? n) ;; 1 ;; (convolve (compose-funs A000045 1+) (compose-funs A000108 1+) (- n 1)) ;; ) ;; ) ;; ;; (map a0similarv2 (iota0 20)) ;; (1 2 4 10 26 73 217 677 2192 7302 24860 86086 302162 1072362 3840952 13865259 50389441 184204645 676875116 2498698161 9262054997) ;; (map a0similarv3 (iota0 20)) ;; (1 1 3 9 26 77 235 741 2406 8009 27211 94006 329229 1166135 4169804 15030784 54558258 199233832 731430790 2697927812 9993479022) (define A014137 (PARTIALSUMS 0 0 A000108)) (define A014138 (PARTIALSUMS 1 1 A000108)) ;; (definec (A014137 n) ;; Partial sums of A000108: 1,2,4,9,23,65,197,... ;; (if (zero? n) ;; 1 ;; (+ (A014137 (-1+ n)) (A000108 n)) ;; ) ;; ) ;; ;; This for the old starting offset: ;; (define (A014138 n) (-1+ (A014137 (1+ n)))) ;; (map A072643 (iota0 23)) ;; n occurs (A000108 n) times. ;; --> (0 1 2 2 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5) ;; Was defined with definec, but without reason: (define (A072643 n) (first_pos_with_funs_val_gte A014137 (1+ n))) ;; Was ranks_w/2 (define (A000245 n) (- (A000108 (1+ n)) (A000108 n))) ;; Most of these are "unnecessary", except A081288, A081291 and A081292. (definec (A081288 n) (first_pos_with_funs_val_gte A000108 (1+ n))) (define (A081289 n) (if (zero? n) n (+ (A014137 (-1+ (A081288 n))) (A000108 (-1+ (A081288 n)))))) (define (A081290 n) (first_pos_with_funs_val_gte A081289 (A081289 n))) (define (A081290v2 n) (if (zero? n) n (A000108 (-1+ (A081288 n))))) (define (A081291 n) (if (zero? n) n (+ (A014137 (-1+ (A081288 n))) n))) (define (A081291v2 n) (+ (A081289 n) (- n (A081290 n)))) (define (A130380 n) (floor->exact (/ (+ (A000108 n) 1) 2))) ;; In gatomain.scm: (define (A081292 n) (A014486 (A081291 n))) (define (A081293 n) (+ (A014137 n) (A000108 n))) (define (A081289v2 n) (if (zero? n) n (A081293 (-1+ (A081288 n))))) ;; A081291 = 0 3 6 7 8 14 15 16 17 18 19 20 21 22 37 38 39 40 41 42 43 ;; More. 82852 --- 82861 reserved. (define (A082852 n) (if (zero? n) 0 (A014137 (-1+ (A072643 n))))) (define (A082853 n) (- n (A082852 n))) (define (A082854 n) (1+ (A082853 n))) ;; A082852 = (0 1 2 2 4 4 4 4 4 9 9 9 9 9 9 9 9 9 9 9 9 9 9 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65) ;; A082853 = (0 0 0 1 0 1 2 3 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55) ;; A014137(n) occurs A000245(n) times. (define (A082855 n) (if (< n 2) n (A014137 (-1+ (A081288 (-1+ n)))))) (define (A081291v3 n) (if (zero? n) n (+ (A082855 (1+ n)) n))) ;; (define A001477v3 (compose-funs A082853 A001477 A081291)) ;; (define A072619v2 (compose-funs A082853 A072088 A081291)) ;; (define A038776v2 (compose-funs A082854 A057117 A081291)) ;; ;; (define (A072088v2 n) (+ (A072619 (A082853 n)) (A082852 n))) ;; A081291 A081289 A081288 A081290 ;; 0 0 0 0 0 ;; ;; 1 3 3 0 2 1 ;; ;; 2 6 6 0 3 2 ;; 3 7 6 1 3 2 ;; 4 8 6 2 3 2 ;; ;; 5 14 14 0 4 5 ;; 6 15 14 1 4 5 ;; 7 16 14 2 4 5 ;; 8 17 14 3 4 ;; 9 18 14 4 4 First pos i where (A081289(i) >= A081289(9)) = 5. ;; 10 19 14 5 4 ;; 11 20 14 6 4 ;; 12 21 14 7 4 ;; 13 22 14 8 4 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Note that: A153141(14)=10, A006068(14)=11 (define (A153141 n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (z n)) (cond ((zero? maskbit) z) ((not (zero? (modulo (floor->exact (/ n maskbit)) 2))) (- z maskbit) ;; Found first 1-bit, complement it, and return ) (else (loop (floor->exact (/ maskbit 2)) (+ z maskbit))) ) ) ) ) ;; Note that A153142(10)=14, while A003188(10)=15 (define (A153142 n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (z n)) (cond ((zero? maskbit) z) ((zero? (modulo (floor->exact (/ n maskbit)) 2)) (+ z maskbit) ;; Found first 0-bit, complement it, and return ) (else (loop (floor->exact (/ maskbit 2)) (- z maskbit))) ) ) ) ) (define A153150 (compose-funs A059893 A056539 A059893)) ;; Abridged/rotated binary decrementing! (define (A153151 n) (cond ((< n 2) n) ((pow2? n) (- (* 2 n) 1)) (else (- n 1)))) ;; Abridged/rotated binary incrementing! (define (A153152 n) (cond ((< n 2) n) ((pow2? (1+ n)) (/ (1+ n) 2)) (else (1+ n)))) (define A153153 (compose-funs A059893 A003188 A059893)) (define A153154 (compose-funs A059893 A006068 A059893)) (define (A153151v2 n) (if (< n 2) n (let loop ((uplim (A053644 n)) (maskbit 1) (z n)) (cond ((= uplim maskbit) z) ((not (zero? (modulo (floor->exact (/ n maskbit)) 2))) (- z maskbit) ;; Found first 1-bit, complement it, and return ) (else (loop uplim (* maskbit 2) (+ z maskbit))) ) ) ) ) (define (A153152v2 n) (if (< n 2) n (let loop ((uplim (A053644 n)) (maskbit 1) (z n)) (cond ((= uplim maskbit) z) ((not (zero? (modulo (floor->exact (/ n maskbit)) 2))) (+ z maskbit) ;; Found first 0-bit, complement it, and return ) (else (loop uplim (* maskbit 2) (- z maskbit))) ) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; New ones, Jan 10 2009 onward: ;; From: ;; Bondarenko, Grigorchuk, Kravchenko, Muntyan, Nekrashevych, Savchuk, Sunic, ;; Classification of groups generated by 3-state automata over ;; a 2-letter alphabet, pp. 8--9 & 103. ;; http://arxiv.org/abs/0803.3555 ;; (find-matching-anum (catfun1 (psi Alamplighter1a)) 2055) --> "A122302" ;; (find-matching-anum (catfun1 (psi Alamplighter2a)) 2055) --> "A122301" ;; ;; (compose-funs A059893 Alamplighter1a A059893) ;; ;; (compose-funs A059893 Alamplighter2a A059893) ;; not present. ;; Here are the 50 A-numbers you requested: A154434 --- A154483. ;; ;; First one on page 104, inverse of the third one: ;; Also A054429-conjugate of the fourth one: ;; (compose-funs A054429 Alamplighter1a A054429) = Alamplighter4a ;; (A054429 A003188 A054429) (define (A154436 n) ;; Alamplighter1a (if (< n 2) n (let loop ((maskbit (A072376 n)) (state 1) (z 1)) (if (zero? maskbit) z (let ((dombit (modulo (floor->exact (/ n maskbit)) 2))) (cond ((= state dombit) (loop (floor->exact (/ maskbit 2)) (- 1 state) (+ z z (modulo (- state dombit) 2)) ) ) (else (loop (floor->exact (/ maskbit 2)) state (+ z z (modulo (- state dombit) 2)) ) ) ) ) ) ) ) ) ;; Third one on the page 104, inverse of the above one: ;; A054429-conjugate of the next one ;; (compose-funs A054429 Alamplighter3a A054429) = Alamplighter2a ;; (A054429 A006068 A054429) (define (A154435 n) ;; Alamplighter2a (if (< n 2) n (let loop ((maskbit (A072376 n)) (state 1) (z 1)) (if (zero? maskbit) z (let ((dombit (modulo (floor->exact (/ n maskbit)) 2))) (cond ((= 0 dombit) (loop (floor->exact (/ maskbit 2)) (- 1 state) (+ z z (modulo (- state dombit) 2)) ) ) (else (loop (floor->exact (/ maskbit 2)) state (+ z z (modulo (- state dombit) 2)) ) ) ) ) ) ) ) ) (define A154438 (compose-funs A059893 A154436 A059893)) ;; (A054429 A153153 A054429) (define A154437 (compose-funs A059893 A154435 A059893)) ;; (A054429 A153154 A054429) ;; Second one on the page 104. = A006068 (define (Alamplighter3a n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (state 1) (z 1)) (if (zero? maskbit) z (let ((dombit (modulo (floor->exact (/ n maskbit)) 2))) (cond ((= 1 dombit) (loop (floor->exact (/ maskbit 2)) (- 1 state) (+ z z (modulo (- state dombit) 2)) ) ) (else (loop (floor->exact (/ maskbit 2)) state (+ z z (modulo (- state dombit) 2)) ) ) ) ) ) ) ) ) ;; Fourth one on page 104, inverse of the second one: = A003188 ;; It's clear that this is (n XOR (n>>1)). (define (Alamplighter4a n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (state 1) (z 1)) (if (zero? maskbit) z (let ((dombit (modulo (floor->exact (/ n maskbit)) 2))) (cond ((not (= state dombit)) (loop (floor->exact (/ maskbit 2)) (- 1 state) (+ z z (modulo (- state dombit) 2)) ) ) (else (loop (floor->exact (/ maskbit 2)) state (+ z z (modulo (- state dombit) 2)) ) ) ) ) ) ) ) ) ;; A154439 = (compose-funs A054429 A154443 A054429) (defineperm1 (A154439 n) ;; Abasilica1a (if (< n 2) n (let loop ((maskbit (A072376 n)) (p 0) (z n)) (cond ((zero? maskbit) z) ((zero? (modulo (floor->exact (/ n maskbit)) 2)) (+ z (* p maskbit)) ;; Found first 0-bit, complement it ;; if at even distance from msb, and return ) (else (loop (floor->exact (/ maskbit 2)) (- 1 p) (- z (* p maskbit)) ) ) ) ) ) ) ;; A154440 = (compose-funs A054429 A154446 A054429) (define (A154440 n) (A154439 (- n))) ;; Abasilica1aINV ;; A154441 = (compose-funs A054429 A154445 A054429) (defineperm1 (A154441 n) ;; Abasilica1b (if (< n 2) n (let loop ((maskbit (A072376 n)) (p 1) (z n)) (cond ((zero? maskbit) z) ((zero? (modulo (floor->exact (/ n maskbit)) 2)) (+ z (* p maskbit)) ;; Found first 0-bit, complement it ;; if at odd distance from msb, and return ) (else (loop (floor->exact (/ maskbit 2)) (- 1 p) (- z (* p maskbit)) ) ) ) ) ) ) ;; A154442 = (compose-funs A054429 A154446 A054429) (define (A154442 n) (A154441 (- n))) ;; Abasilica1bINV (defineperm1 (A154443 n) ;; Abasilica2a (if (< n 2) n (let loop ((maskbit (A072376 n)) (p 0) (z n)) (cond ((zero? maskbit) z) ((not (zero? (modulo (floor->exact (/ n maskbit)) 2))) (- z (* p maskbit)) ;; Found first 1-bit, complement it ;; if at odd distance, and return ) (else (loop (floor->exact (/ maskbit 2)) (- 1 p) (+ z (* p maskbit)) ) ) ) ) ) ) (define (A154444 n) (A154443 (- n))) ;; Abasilica2aINV (defineperm1 (A154445 n) ;; Abasilica2b (if (< n 2) n (let loop ((maskbit (A072376 n)) (p 1) (z n)) (cond ((zero? maskbit) z) ((not (zero? (modulo (floor->exact (/ n maskbit)) 2))) (- z (* p maskbit)) ;; Found first 1-bit, complement it ;; if at odd distance, and return ) (else (loop (floor->exact (/ maskbit 2)) (- 1 p) (+ z (* p maskbit)) ) ) ) ) ) ) (define (A154446 n) (A154445 (- n))) ;; Abasilica2bINV ;; These are inverses of each other: (define (A154448 n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (p 1) (z n)) (cond ((zero? maskbit) z) ((= p (modulo (floor->exact (/ n maskbit)) 2)) (+ z (* (- 1 (* 2 p)) maskbit)) ;; Found first bit ;; equal to p, complement it if at odd distance, and return ) (else (loop (floor->exact (/ maskbit 2)) (- 1 p) (- z (* (- 1 (* 2 p)) maskbit)) ) ) ) ) ) ) (define (A154447 n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (p 0) (z n)) (cond ((zero? maskbit) z) ((= p (modulo (floor->exact (/ n maskbit)) 2)) (+ z (* (- 1 (* 2 p)) maskbit)) ;; Found first bit ;; equal to p, complement it if at odd distance, and return ) (else (loop (floor->exact (/ maskbit 2)) (- 1 p) (- z (* (- 1 (* 2 p)) maskbit)) ) ) ) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Lei Zhou's sequences: ;; Needs either GF2Xfuns from this same directory ;; or (load "c:\\slib\\mitscheme.init") ;; and (require 'factor) ;; (for prime? function, and factor) ;; (Offset=4) ;; %S A103151 1,1,2,1,3,2,2,2,3,3,4,2,4,2,4,4,4,4,5,3,4,6,5,3,6,3,3,6,6,5,7, ; Number of decompositions of 2n+1 into ordered sums of one odd prime and two times another odd prime. ;; a(n) = count of all eligible p1 for 2n+1 = 2*p1 + p2; where p1 and p2 are prime numbers. (definec (A103151 n) (let loop ((i 2) (z 0)) (let ((p1 (A000040 i))) (cond ((>= p1 n) z) ((prime? (+ 1 (* 2 (- n p1)))) (loop (+ 1 i) (+ 1 z))) (else (loop (+ 1 i) z)) ) ) ) ) ;; Another variant: (definec (A103151v2 n) (let ((o (+ (* 2 n) 1))) (let loop ((i 2) (z 0)) (let ((p2 (A000040 i))) (cond ((> p2 (- o 6)) z) ((prime? (/ (- o p2) 2)) (loop (+ 1 i) (+ 1 z))) (else (loop (+ 1 i) z)) ) ) ) ) ) ;; %N A103152 Smallest odd number which is the sum of an odd prime and twice another odd prime ;; (can be equal to the first) in exactly n ways. (definec (A103152 n) (+ 1 (* 2 (first-n-where-fun_n-is-i1 A103151 n)))) ;; %N A103507 Index of the smallest prime in decomposition of 2n+1 into sum of twice of this odd ;; prime and another odd prime. (and 0 if no such prime exists). ;; %F A103507 PrimePi[A103153] (definec (A103507 n) (let loop ((i 2)) (let ((p1 (A000040 i))) (cond ((>= p1 n) 0) ((prime? (+ 1 (* 2 (- n p1)))) i) (else (loop (+ 1 i))) ) ) ) ) ; %N A103153 Smallest prime in decomposition of 2n+1 into sum of twice of this prime and another prime. ; (and 0 if there are cases where the conjecture given in A103151 does not hold.) ; (and 0 if no such prime exists) (define (A103153 n) (let ((ind (A103507 n))) (if (zero? ind) 0 (A000040 ind)))) (definec (A103509 n) (let ((o (+ (* 2 n) 1))) (let loop ((i 2)) (let ((p2 (A000040 i))) (cond ((> p2 (- o 6)) 0) ((prime? (/ (- o p2) 2)) i) (else (loop (+ 1 i))) ) ) ) ) ) ;; %N A103509 Index of the smallest prime in decomposition of 2n+1 into sum of this odd prime ;; and twice of another odd prime. (and 0 if no such prime exists). (define (A103506 n) (let ((ind (A103509 n))) (if (zero? ind) 0 (A000040 ind)))) ;; Minimum prime p2, such that |A000040(n)-p2| is of the form 2^k. (definec (A130970 n) (let ((p1 (A000040 n))) (let loop ((i 1)) (cond ((pow2? (abs (- p1 (A000040 i)))) (A000040 i)) (else (loop (+ i 1))) ) ) ) ) ;; Minimum prime p2, such that either |A000040(n)-p2| or A000040(n)+p2 is of the form 2^k. (definec (A130971 n) (let ((p1 (A000040 n))) (let loop ((i 1) (p2 2)) (cond ((pow2? (abs (- p1 p2))) p2) ((pow2? (+ p1 p2)) p2) (else (loop (+ i 1) (A000040 (+ i 1)))) ) ) ) ) (define A130972 (RECORD-POS 1 1 A130971)) (define A103150 (RECORD-VALS 1 1 A130971)) (define (A103149 n) (if (= n 1) 3 (A000040 (A130972 n)) ) ) (define A103149v2 (compose-funs A000040 (RECORD-POS 2 2 A130971) 1+)) (definec (A103508 n) (+ 1 (* 2 (first-n-where-fun_n-is-i1 A103507 (+ 1 n))))) (definec (A103510 n) (+ 1 (* 2 (first-n-where-fun_n-is-i1 A103509 (+ 1 n))))) ;; A103149 & A103150: starting offset changed to o=1. ;; Here are the 10 A-numbers you requested: A140259 --- A140268. (definec (A140259 n) (cond ((zero? n) 3) ((= 1 (A140259 (- n 1))) (A002264 (+ n 11))) ((not (zero? (modulo (- n 1) 3))) (- (A140259 (- n 1)) 1)) (else (A140259 (- n 1))) ) ) (define A140260 (MATCHING-POS 0 0 (lambda (i) (= (A140259 i) (A002264 (+ i 11)))))) (define (A140261 n) (A140259 (A140260 n))) (define (A140262 n) (modulo (A140260 n) 9)) (define (A117966 n) ;; 0,1,-1,3,4,2,-3,-2,-4,9,10,8,12,... (let loop ((z 0) (i 0) (n n)) (if (zero? n) z (loop (+ z (* (expt 3 i) (if (= 2 (modulo n 3)) -1 (modulo n 3)))) (1+ i) (floor->exact (/ n 3)) ) ) ) ) ;; When applied to natural numbers >= 1, gives: ;; i.e. a bisection of the next sequence. ;; Inverse of A117966: ;; (map A117967 (map A117966 (iota0 729))) = (iota0 729) ;; Gives a non-negative integer, which when converted to ternary ;; and interpreted as _balanced ternary_, is equal to argument z. ;; When restricted to non-negative integers, gives A117967. (define (A117967 z) (cond ((zero? z) 0) ((negative? z) (A004488 (A117967 (- z)))) (else ;; z is positive. (let* ((lp3 (expt 3 (A062153 z))) ;; largest power of three of z. (np3 (* 3 lp3)) ;; Next Power of Three. ) (if (< (* 2 z) np3) ;; z less than np3/2 (+ lp3 (A117967 (- z lp3))) (+ np3 (A117967 (- z np3))) ) ) ) ) ) ;; Based on Frank's: ;; a(0) = 0, a(3n) = 3a(n), a(3n+1) = 3a(n)+1, a(3n-1) = 3a(n)+2. (define (A117967v2 z) (cond ((zero? z) 0) ((negative? z) (A004488 (A117967v2 (- z)))) ((zero? (modulo z 3)) (* 3 (A117967v2 (/ z 3)))) ((= 1 (modulo z 3)) (+ (* 3 (A117967v2 (/ (- z 1) 3))) 1)) (else (+ (* 3 (A117967v2 (/ (+ z 1) 3))) 2)) ;; z = 2 (= -1) modulo 3. ) ) (define (A117968 n) (A117967 (- n))) ;; (define (A117968v2 n) (A004488 (A117967 n))) (define (A140263 n) (A117967 (A001057 n))) ;; Zero-based. (define (A140264 n) (- (A140266 (+ 1 n)) 1)) (define (A140265 n) (+ 1 (A140263 (- n 1)))) ;; One-based. (define (A140266 n) (Z->N (A117966 (- n 1)))) (define (A140267 n) (A007089 (A117967 n))) ;; 1,12,10,11,122,120,121,102,100 ;; 2,21,20,22,211,210,212,201,200,202,221,220,222,2111,2110,2112,2101,2100,... (define (A140268 n) (A007089 (A117968 n))) ;; Added 2012-03-03: ;; Essentially rewrites in binary expansion of n each 0 -> 01, 1X -> 1(rewrite X)0, ;; where X is the maximal suffix after the 1-bit. (definec (A071162 n) (let loop ((n n) (s 0) (i 1)) (cond ((zero? n) s) ((even? n) (loop (/ n 2) (+ s i) (* i 4))) (else (loop (/ (- n 1) 2) (* 2 (+ s i)) (* i 4))) ) ) ) ;; Some kind of "inverse" of A071162: ;; Rewrite from the msb end, 1 -> 1, 0+1 -> 0, stop when only zeros left. (definec (A209859 n) (let loop ((n n) (s 0) (i (A053644 n))) (cond ((zero? n) s) ((> i n) ;; Found zero-bit (from the left) (if (> (/ i 2) n) ;; Is also the next bit to the right zero? (loop n s (/ i 2)) ;; Then keep the s still same. (loop (- n (/ i 2)) (* 2 s) (/ i 4)) ;; Otherwise skip the 1, and double the s. ) ) (else (loop (- n i) (+ (* 2 s) 1) (/ i 2))) ) ) ) (define A209639 (compose-funs A209859 A005408)) ;; As A014486 but also bit pattern 10+11 is forbidden. ;; (That is, if there are any adjacent 1's, they must all be located ;; as part of the leftmost prefix of n.) (define (member_of_A209641? n) ;; and also of A209642 (let loop ((n n) (lev 0)) (cond ((zero? n) (zero? lev)) ((< lev 0) #f) ((even? n) (loop (/ n 2) (+ lev 1))) ;; So now we now we have found 1-bit. ((and (odd? (/ (-1+ n) 2)) ;; Is the next bit (to the left) also 1? (even? (/ (-1+ (/ (-1+ n) 2)) 2)) ;; and the next after that is 0? (not (zero? (/ (-1+ (/ (-1+ n) 2)) 2))) ;; but not past the msb yet? ) #f ;; Our forbidden pattern found. ) (else (loop (/ (- n 1) 2) (- lev 1))) ) ) ) (define *MAX-CACHE-SIZE-FOR-DEFINEC* (expt 2 20)) ;; 290512 ;; Was 131072 (define A209641 (MATCHING-POS 0 0 member_of_A209641?)) ;; A209635-A209644 are now reserved for your use. ;; A209859-A209868 ;; Modified from the CatalanRank in gatorank.scm: ;; Hypothesis: If we have w upward slopes, of which u start a leftmost upward prefix, ;; then we have altogether C(w-1,u) = C(w-1,w-1-u) ways to arrange the other w-u upward slopes ;; in such a way that no forbidden ;; / ;; pattern: / ;; occurs anywhere. ;; Proof: from the Comments of A007318: ;; C(n+k-1,n-1) is the number of ways of placing k indistinguishable balls ;; into n boxes (the "bars and stars" argument - see Feller). ;; I.e. as k=w-u and n=u, we have C(w-1,u-1) ;; ;; After the the first \ (from left), when we first encounter a first /\ ;; at level lev (= [1,u]) it means there are C(lev-1,w-u-1) ways to arrange ;; lexicographically less paths (with downward slope \ instead of upward slope /) ;; "between" (zero is lev = 1). ;; ;; w=4, u=1, C(3,0) = 1 ;; /\/\/\/\ ;; ;; ;; w=4, u=2, C(3,1) = 3 ;; /\ /\/\ /\/\/\ ;; / \/\/\ / \/\ / \ ;; 0+2 1+1 2+0 ;; ;; ;; w=4, u=3, C(3,2) = 3 ;; (3 1) = 3 ;; ;; /\ /\ /\/\ ;; / \ / \/\ / \ ;; / \/\ / \ / \ ;; ;; ;; (2 1) + (2 2) = (3 2) = 3 = (3 1) = 3 (ways to insert + among " 1 1 "). ;; ;; 2^(4-1) = 8. ;; ;; (4 0) = 1 ;; w=4, u=4, C(3,3) = 1 ;; ;; /\ ;; / \ ;; / \ ;; / \ ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 2^(4-1) = 8. ;; ;; (5 0) = (4 0) = 1 ;; ;; /\ ;; / \ ;; / \ ;; / \ ;; / \ ;; ;; (4 1) = 4 ;; ;; /\ /\ /\ /\/\ ;; / \ / \ / \/\ / \ ;; / \ / \/\ / \ / \ ;; / \/\ / \ / \ / \ ;; ;; ;; (3 1) + (3 2) = (4 2) = 6 ;; That is, 3 cases where the remaining /\'s come at the same level, ;; and 3 cases where they come at different levels: ;; ;; /\ /\ /\ /\/\ /\/\ /\/\/\ ;; / \ / \/\ / \/\/\ / \ / \/\ / \ ;; / \/\/\ / \/\ / \ / \/\ / \ / \ ;; 0+0+2 0+1+1 0+2+0 1+0+1 1+1+0 2+0+0 ;; ;; ;; (4 1) = 4 (ways to insert + among " 1 1 1 ")= (4 3) ;; ;; /\ /\/\ /\/\/\ /\/\/\/\ ;; / \/\/\/\ / \/\/\ / \/\ / \ ;; 0+3 1+2 2+1 3+0 ;; ;; (1 1) = 1 = (4 4) ;; ;; /\/\/\/\/\ ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 2^(5-1) = 16. ;; ;; (6 0) = (5 0) = 1 ;; ;; /\ ;; / \ ;; / \ ;; / \ ;; / \ ;; / \ ;; ;; (5 1) = 5 ;; ;; /\ /\ /\ /\ /\/\ ;; / \ / \ / \ / \/\ / \ ;; / \ / \ / \/\ / \ / \ ;; / \ / \/\ / \ / \ / \ ;; / \/\ / \ / \ / \ / \ ;; ;; ;; (4 1) + (4 2) = 4 + 6 = 10 = (5 2) ;; ;; /\ /\ /\ /\ /\ ;; / \ / \ / \ / \/\ / \/\ ;; / \ / \/\ / \/\/\ / \ / \/\ ;; / \/\/\ / \/\ / \ / \/\ / \ ;; ^ ^ ^ ^ ;; (sr += 1) (ssr += 1) (sr += 3) (ssr += 1) ;; (3 1) ( 0+2, 1+1, 2+0 ) ;; = (2 1) + (2 2) = (3 2) ;; ;; ;; /\ /\/\ /\/\ /\/\ /\/\/\ ;; / \/\/\ / \ / \ / \/\ / \ ;; / \ / \ / \/\ / \ / \ ;; / \ / \/\ / \ / \ / \ ;; ^ ^ ^ ^ ^ ;; (ssr += 2) (sr += 6) (ssr += 1) (ssr += 2) (ssr += 3) ;; (4 2) ;; (from the previous the peak /\ can be cut off, and then we have ;; recursively regressed to one smaller case). ;; ;; ;; (3 1) + (3 3) + 2*(3 2) = 3 + 1 + 6 = 10 = (5 2) = (5 3) = (4 2) + (4 1) ;; That is, 3 cases where the remaining /\'s come at the same level, ;; and 1 case where they all go to the different levels, ;; and 6 cases where they are divided to two different levels: ;; ;; 0+0+3 0+1+2 0+2+1 0+3+0 1+0+2 ;; /\ /\ /\ /\ /\/\ ;; / \ / \/\ / \/\/\ / \/\/\/\ / \ ;; / \/\/\/\ / \/\/\ / \/\ / \ / \/\/\ ;; +1 ^ +1 ^ +1 ^ +4 ^ = (4 1) ( 0+3, 1+2, 2+1, 3+0 ) ;; ;; 1+1+1 1+2+0 2+0+1 2+1+0 3+0+0 ;; /\/\ /\/\ /\/\/\ /\/\/\ /\/\/\/\ ;; / \/\ / \/\/\ / \ / \/\ / \ ;; / \/\ / \ / \/\ / \ / \ ;; +1 ^ +1 ^ 4 3 +1^ 4 3 2 ;; ;; ;; (5 1) = 5 (ways to insert + among " 1 1 1 1 ") = (5 4). ;; ;; /\ /\/\ /\/\/\ /\/\/\/\ /\/\/\/\/\ ;; / \/\/\/\/\ / \/\/\/\ / \/\/\ / \/\ / \ ;; 0+4 1+3 2+2 3+1 4+0 ;; ;; ;; (1 1) = 1 = (5 5) ;; /\/\/\/\/\/\ ;; ;; Hypothesis: If we have w upward slopes, of which u start a leftmost upward prefix, ;; C(w-1,u-1) ;; then we have altogether C(w-1,u-1) = C(w-1,w-1-(u-1)) = C(w-1,w-u) ways to arrange the other w-u upward slopes ;; in such a way that no forbidden ;; / ;; pattern: / ;; occurs anywhere. ;; Proof: from the Comments of A007318: ;; C(n+k-1,n-1) is the number of ways of placing k indistinguishable balls ;; into n boxes (the "bars and stars" argument - see Feller). ;; My note: C(n+k-1,n-1) = C(n+k-1,(n+k-1)-(n-1)) = C(n+k-1,k) ;; Thus, when we set w = n+k and u=k we get C(n+k,k) from above. ;; ;; ;; After the the first \ (from left), when we first encounter a first /\ ;; at level lev (= [1,u]) it means there are C(lev-1,w-u-1) ways to arrange ;; lexicographically less paths (with downward slope \ instead of upward slope /) ;; "between" (zero is lev = 1). ;; ;; Seems to work now... ;; (define (A209640 n) ;; The totally balanced binary expansion with restrictions (if (or (zero? n) (not (member_of_A209641? n))) ;; Check the restrictions. 0 (let* ((w (/ (binwidth n) 2))) (let loop ((rank 0) (row 1) (u (- w 1)) (n (- n (A053644 n))) (i (/ (A053644 n) 2)) ;; Start scanning from the second most significant bit. (first_0_found? #f) ) ;; (format #t "n=~a i=~a row=~a u=~a first_0_found?=~a rank=~a\n" n i row u first_0_found? rank) (cond ((or (zero? row) (zero? u) (zero? n)) (+ (expt 2 (-1+ w)) rank)) ((> i n) ;; (zero? (modulo a 2)) (loop ;; Down, down, down... rank ;; stays the same. (- row 1) ;; We go one row topwards in Khayyam's triangle. u ;; We have the same number of upward steps after this downward step. n (/ i 2) #t ;; At least now we have found the first or some subsequent zero. ) ) (else ;; At this point both row and u and n must be >= 1. (loop ;; Up the mountain high. (+ rank (if first_0_found? (A007318tr (- (+ row u) 1) (- row 1)) (A007318tr (- w 1) (- row 1)) ) ) (+ row 1) (- u 1) ;; One up-step less left to use after this. (- n i) (/ i 2) first_0_found? ) ) ) ) ) ) ) (define (A209861 n) (A209640 (A209642 n))) (define (A209862 n) (A209859 (A036044 (A209641 n)))) (define (compute-and-print-cycle-vectors-for-A209861 outfile upto-n) (compute-and-print-generic-cycle-vectors A209861 indices-of-nth-binary-forest outfile upto-n ) ) ;; Conjecture: for every A209860(n), also A054429(A209860(n)) is in the sequence. (define A209860 (MATCHING-POS 0 0 (lambda (i) (= (A209861 i) i)))) (define A209863 (fc-generic-Afun A209861 range-of-nth-binary-forest)) (define A209864 (cc-generic-Afun A209861 indices-of-nth-binary-forest)) (define A209865 (mc-generic-Afun A209861 indices-of-nth-binary-forest)) (define A209866 (lc-generic-Afun A209861 indices-of-nth-binary-forest)) (define A209867 (elements-on-odd-orbits-generic-Afun A209861 indices-of-nth-binary-forest)) (define A209868 (elements-on-even-orbits-generic-Afun A209861 indices-of-nth-binary-forest)) (define (A209636 n) (let loop ((n (* 2 n)) (m 1)) (cond ((< n 2) m) ((even? n) (loop (/ n 2) (* m 2))) (else (loop (/ (- n 1) 2) (A000040 m))) ) ) ) (define (A209636v2 n) (A127301 (A071163 n))) (define (A209636v3 n) (A209637 (A054429 n))) (define (A209637 n) (A209636 (A054429 n))) (define (A209637v2 n) (A127301 (A057505 (A071163 n)))) (define (A209637v3 n) (A127301 (A057163 (A071163 n)))) ;; Compare with A071162: (define (A209642 n) (let loop ((n n) (s 0) (i 1)) (cond ((zero? n) s) ((even? n) (loop (/ n 2) (+ (* 4 s) 1) (* i 4))) (else (loop (/ (- n 1) 2) (* 2 (+ s i)) (* i 4))) ) ) ) (define A209642v3 (compose-funs A056539 A071162)) (define A209642v4 (compose-funs A036044 A071162)) (define Anewperm1 (compose-funs A209861 A054429)) (define Anewperm1v2 (compose-funs A054429 A209861)) (define Anewperm2 (compose-funs A209862 A054429)) (define Anewperm2v2 (compose-funs A054429 A209862)) (define (A209635 n) (A008683 (A000265 n))) ;; Multiplicative. (define A122132 (NONZERO-POS 1 1 A209635)) ;; Complement to next. (define A038838 (ZERO-POS 1 1 A209635))