OFFSET
0,5
COMMENTS
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..5040
FORMULA
In other words, if n is either zero or one of the terms of A051683, then a(n) = A099563(n) [the most significant digit of its f.b.r.], otherwise take the minimum of the most significant digit and a(A257687(n)) [value computed by recursing with a smaller value obtained by discarding that most significant digit].
Other identities:
For all n >= 0, a(A001563(n)) = n. [n * n! gives the first position where n appears. Note also that the "digits" (placeholders) in factorial base representation may get arbitrarily large values.]
For all n >= 0, a(2n+1) = 1 [because all odd numbers end with digit 1 in factorial base].
EXAMPLE
Factorial base representation (A007623) of 4 is "20", the smallest digit which is not zero is "2", thus a(4) = 2.
MATHEMATICA
a[n_] := Module[{k = n, m = 2, rmin = n, r}, While[{k, r} = QuotientRemainder[k, m]; k != 0 || r != 0, If[0 < r < rmin, rmin = r]; m++]; rmin]; Array[a, 100, 0] (* Amiram Eldar, Jan 23 2024 *)
PROG
(Scheme)
(define (A257679 n) (let loop ((n n) (i 2) (mind 0)) (if (zero? n) mind (let ((d (modulo n i))) (loop (/ (- n d) i) (+ 1 i) (cond ((zero? mind) d) ((zero? d) mind) (else (min d mind))))))))
;; Alternative implementations based on given recurrences, using memoizing definec-macro:
(Python)
def A(n, p=2):
return n if n<p else A(n//p, p+1)*10 + n%p
def a(n):
return 0 if n==0 else min(int(i) for i in str(A(n)) if i !='0')
print([a(n) for n in range(201)]) # Indranil Ghosh, Jun 19 2017
CROSSREFS
Positions of records: A001563.
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, May 04 2015
STATUS
approved