A257260 One-based position of the rightmost zero in the factorial base representation of n (A007623), 0 if no nonleading zeros present.
0, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 3, 1, 3, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 3, 1, 3, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 3, 1, 3, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 3, 1, 3, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1
Offset: 1
Examples
For n = 1, with factorial base representation (A007623) "1", there are no nonleading zeros at all, thus a(1) = 0. For n = 6, with representation "100", the rightmost zero occurs at digit-position 1 (when the least significant digit has index 1, etc.), thus a(6) = 1. For n = 7, with representation "101", the rightmost zero occurs at position 2, thus a(7) = 2.
Links
Crossrefs
Programs
-
Mathematica
a[n_] := Module[{k = n, m = 2, r, s = {}, p}, While[{k, r} = QuotientRemainder[k, m]; k != 0|| r != 0, AppendTo[s, r]; m++]; If[MissingQ[(p = FirstPosition[s, 0])], 0, p[[1]]]]; Array[a, 100] (* Amiram Eldar, Feb 07 2024 *)
-
Scheme
(define (A257260 n) (let loop ((n n) (i 2)) (cond ((zero? n) 0) ((zero? (modulo n i)) (- i 1)) (else (loop (floor->exact (/ n i)) (+ 1 i))))))
Comments