cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A297815 Number of positive integers with n digits whose digit sum is equal to its digit product.

Original entry on oeis.org

9, 1, 6, 12, 40, 30, 84, 224, 144, 45, 605, 495, 1170, 1092, 210, 240, 2448, 4896, 15846, 3420, 1750, 462, 15939, 0, 8100, 67925, 80730, 19656, 11774, 164430, 930, 29760, 197472, 0, 0, 1260, 23976, 50616, 54834, 395200, 1248860, 4253340, 75852, 0, 42570
Offset: 1

Views

Author

Reiner Moewald, Jan 06 2018

Keywords

Examples

			The only term with two digits is 22: 2 * 2 = 2 + 2.
		

Crossrefs

Programs

  • Mathematica
    cperm[w_] := Length[w]!/Times @@ ((Last /@ Tally[w])!); ric[s_, p_, w_, tg_] := Block[{d}, If[tg == 0, If[s == p, tot += cperm@ w], Do[ If[p*d > s + d + (tg-1)*9, Break[]]; ric[s+d, p*d, Append[w,d], tg-1], {d, Last@ w, 9}]]]; a[n_] := (tot=0; ric[#, #, {#}, n-1] & /@ Range[9]; tot); Array[a, 45] (* Giovanni Resta, Feb 05 2018 *)
  • Python
    import math
    def digitProd(natNumber):
        digitProd = 1
        for letter in str(natNumber):
            digitProd *= int(letter)
        return digitProd
    def digitSum(natNumber):
        digitSum = 0
        for letter in str(natNumber):
            digitSum += int(letter)
        return digitSum
    for n in range(24):
        count = 0
        for a in range(int(math.pow(10,n)), int(math.pow(10, n+1))):
            if digitProd(a) == digitSum(a):
                count += 1
        print(n+1, count)
    
  • Python
    from sympy.utilities.iterables import combinations_with_replacement
    from sympy import prod, factorial
    def A297815(n):
        f = factorial(n)
        return sum(f//prod(factorial(d.count(a)) for a in set(d)) for d in combinations_with_replacement(range(1,10),n) if prod(d) == sum(d)) # Chai Wah Wu, Feb 06 2018

Extensions

a(10) and a(23) corrected by and a(25)-a(45) from Giovanni Resta, Feb 05 2018