OFFSET
0,10
COMMENTS
a(n) = Number of times a nonzero digit d_i appears in such position i of factorial base representation of n for which there is another nonzero digit in position i - d_i. Here one-based indexing is used for digits, thus the least significant digit is in position 1.
LINKS
EXAMPLE
For n=15 ("211" in factorial base) both 2 at position 3 and 1 at position 2 hit the least significant 1 at position 1 as (2-1) = (3-2) = 1, the position where the least significant 1 itself is. These both cases are included in the count, because this sequence counts the total number of hitting digits, thus a(15)=2.
PROG
(Scheme)
(define (A276007 n) (let ((fv (list->vector (cons 0 (reverse (n->factbase n)))))) (let loop ((i 1) (c 0)) (if (>= i (vector-length fv)) c (let ((d (vector-ref fv i))) (if (zero? d) (loop (+ 1 i) c) (loop (+ 1 i) (+ c (if (not (zero? (vector-ref fv (- i d)))) 1 0)))))))))
(define (n->factbase n) (let loop ((n n) (fex (if (zero? n) (list 0) (list))) (i 2)) (cond ((zero? n) fex) (else (loop (floor->exact (/ n i)) (cons (modulo n i) fex) (+ 1 i))))))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Aug 17 2016
STATUS
approved