;; ;; The following Scheme-function was used to compute the terms of OEIS-entry A293220 ;; and its b-file, 2017-10-10. Written by Antti Karttunen, after the description of ;; Vladimir Shevelev. ;; (define (A293220 n) (define (next_one k m) (if (zero? (modulo (+ k m) 3)) (+ k m) (+ k m m))) (let* ((u (A001651 n)) (x_init (next_one 1 u)) ) (let loop ((x x_init) (z (A038502 x_init))) (let ((r (A038502 x))) (if (= 1 r) z (let ((x_next (next_one r u))) (loop x_next (+ z (A038502 x_next)) ) ) ) ) ) ) ) (define (A053446 n) (define (next_one k m) (if (zero? (modulo (+ k m) 3)) (+ k m) (+ k m m))) (let* ((u (A001651 n)) (x_init (next_one 1 u)) ) (let loop ((x x_init) (s (A007949 x_init))) (let ((r (A038502 x))) (if (= 1 r) s (let ((x_next (next_one r u))) (loop x_next (+ s (A007949 x_next))) ) ) ) ) ) ) (define (A001651 n) (let ((x (- n 1))) (if (even? x) (+ 1 (* 3 (/ x 2))) (- (* 3 (/ (+ x 1) 2)) 1)))) (define (A038502 n) (/ n (A038500 n))) (define (A038500 n) (A000244 (A007949 n))) (define (A007949 n) (if (zero? n) 0 (let loop ((n n) (k 0)) (cond ((not (zero? (modulo n 3))) k) (else (loop (/ n 3) (+ 1 k))) ) ) ) ) (define (A000244 n) (expt 3 n))