login
Product of nonzero digits of n in factorial base.
11

%I #29 Feb 07 2024 01:16:30

%S 1,1,1,1,2,2,1,1,1,1,2,2,2,2,2,2,4,4,3,3,3,3,6,6,1,1,1,1,2,2,1,1,1,1,

%T 2,2,2,2,2,2,4,4,3,3,3,3,6,6,2,2,2,2,4,4,2,2,2,2,4,4,4,4,4,4,8,8,6,6,

%U 6,6,12,12,3,3,3,3,6,6,3,3,3,3,6,6,6,6,6,6

%N Product of nonzero digits of n in factorial base.

%C a(0) = 1 as an empty product always gives 1.

%H Antti Karttunen, <a href="/A227153/b227153.txt">Table of n, a(n) for n = 0..5040</a>

%F For all n, a(A227157(n)) = A208575(A227157(n)).

%t a[n_] := Module[{k = n, m = 2, r, p = 1}, While[{k, r} = QuotientRemainder[k, m]; k != 0|| r != 0, If[r > 0, p *= r]; m++]; p]; Array[a, 100, 0] (* _Amiram Eldar_, Feb 07 2024 *)

%o (MIT/GNU Scheme)

%o (define (A227153 n) (apply * (delete-matching-items (n->factbase n) zero?)))

%o (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))))))

%o (Python)

%o from operator import mul

%o def A(n, p=2):

%o return n if n<p else A(n//p, p+1)*10 + n%p

%o def a(n):

%o return 1 if n<2 else reduce(mul, [int(i) for i in str(A(n - 1)) if i!="0"])

%o print([a(n) for n in range(201)]) # _Indranil Ghosh_, Jun 19 2017

%Y A227157 gives the positions where equal with A208575.

%Y Cf. A007623, A227154, A227191.

%K nonn,base

%O 0,5

%A _Antti Karttunen_, Jul 04 2013