login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A051801 Product of the nonzero digits of n. 42

%I #59 Apr 16 2023 16:41:39

%S 1,1,2,3,4,5,6,7,8,9,1,1,2,3,4,5,6,7,8,9,2,2,4,6,8,10,12,14,16,18,3,3,

%T 6,9,12,15,18,21,24,27,4,4,8,12,16,20,24,28,32,36,5,5,10,15,20,25,30,

%U 35,40,45,6,6,12,18,24,30,36,42,48,54,7,7,14,21

%N Product of the nonzero digits of n.

%H Zak Seidov and Michael De Vlieger, <a href="/A051801/b051801.txt">Table of n, a(n) for n = 0..10000</a> (First 1000 terms from Zak Seidov)

%H <a href="/index/Coi#Colombian">Index entries for Colombian or self numbers and related sequences</a>

%F a(n) = 1 if n=0, otherwise a(floor(n/10)) * (n mod 10 + 0^(n mod 10)). - _Reinhard Zumkeller_, Oct 13 2009

%F G.f. A(x) satisfies: A(x) = (1 + x + 2*x^2 + 3*x^3 + 4*x^4 + 5*x^5 + 6*x^6 + 7*x^7 + 8*x^8 + 9*x^9) * A(x^10). - _Ilya Gutkovskiy_, Nov 14 2020

%F a(n) = A007954(A004719(n)). - _Michel Marcus_, Mar 07 2022

%e a(0) = 1 since an empty product is 1 by convention. a(120) = 1*2 = 2.

%p A051801 := proc(n) local d,j: d:=convert(n,base,10): return mul(`if`(d[j]=0,1,d[j]), j=1..nops(d)): end: seq(A051801(n),n=0..100); # _Nathaniel Johnston_, May 04 2011

%t (Times@@Cases[IntegerDigits[#],Except[0]])&/@Range[0,80] (* _Harvey P. Dale_, Jun 20 2011 *)

%t Table[Times@@(IntegerDigits[n]/.(0->1)),{n,0,80}] (* _Harvey P. Dale_, Apr 16 2023 *)

%o (Haskell)

%o a051801 0 = 1

%o a051801 n = (a051801 n') * (m + 0 ^ m) where (n',m) = divMod n 10

%o -- _Reinhard Zumkeller_, Nov 23 2011

%o (PARI) a(n)=my(v=select(k->k>1,digits(n)));prod(i=1,#v,v[i]) \\ _Charles R Greathouse IV_, Nov 20 2012

%o (Python)

%o from operator import mul

%o from functools import reduce

%o def A051801(n):

%o return reduce(mul, (int(d) for d in str(n) if d != '0')) if n > 0 else 1 # _Chai Wah Wu_, Aug 23 2014

%o (Python)

%o from math import prod

%o def a(n): return prod(int(d) for d in str(n) if d != '0')

%o print([a(n) for n in range(74)]) # _Michael S. Branicky_, Jul 18 2021

%o (Swift 5)

%o A051801(n): String(n).compactMap{$0.wholeNumberValue == 0 ? 1 : $0.wholeNumberValue}.reduce(1, *) // _Egor Khmara_, Jan 15 2021

%Y Basis for A051802.

%Y See A338882 for similar sequences.

%Y See also A007953 (digital sum).

%Y Cf. A004719, A007954.

%K nonn,easy,base,nice

%O 0,3

%A _Dan Hoey_, Dec 09 1999

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 07:53 EDT 2024. Contains 371964 sequences. (Running on oeis4.)