Summing of product of digits

Algebra Level 2

Define p ( n ) p(n) to be the product of all non-zero digits of n n . For instance p ( 7 ) = 7 p(7)=7 , p ( 39 ) = 27 p(39)=27 , p ( 102 ) = 2 p(102)=2 and so on. Find the greatest prime divisor of the following expression p ( 1 ) + p ( 2 ) + p ( 3 ) + . . . + p ( 999 ) p(1)+p(2)+p(3)+...+p(999)


The answer is 103.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Hongqi Wang
Nov 14, 2020
  • one dig numbers: p 1 = i = 1 9 p ( i ) = i = 1 9 i = 45 \\ p_1 = \sum\limits_{i=1}^9 p(i) = \sum\limits_{i=1}^9 i = 45

  • two digits numbers: p 2 = i = 10 99 p ( i ) = i = 1 9 p ( 10 i ) + i = 1 9 j = 1 9 p ( 10 i + j ) = i = 1 9 i + i = 1 9 j = 1 9 ( i × j ) = i = 1 9 i + i = 1 9 i × j = 1 9 j = p 1 + p 1 × p 1 = p 1 ( p 1 + 1 ) \\ p_2 = \sum\limits_{i=10}^{99} p(i) \\ = \sum\limits_{i=1}^9 p(10i) + \sum\limits_{i=1}^9 \sum\limits_{j=1}^9 p(10i+j) \\ = \sum\limits_{i=1}^9 i + \sum\limits_{i=1}^9 \sum\limits_{j=1}^9 (i \times j) \\ = \sum\limits_{i=1}^9 i + \sum\limits_{i=1}^9 i \times \sum\limits_{j=1}^9 j \\ = p_1 + p_1 \times p_1 \\ = p_1(p_1 + 1)

  • three digits numbers: p 3 = i = 100 999 p ( i ) = i = 1 9 ( j = 0 99 p ( 100 i + j ) ) = i = 1 9 ( p ( 100 i ) + j = 1 99 p ( 100 i + j ) ) = i = 1 9 p ( 100 i ) + i = 1 9 ( j = 1 99 p ( 100 i + j ) ) = p 1 + i = 1 9 ( i × j = 1 99 p ( j ) ) = p 1 + i = 1 9 ( i × ( p 1 + p 2 ) ) = p 1 + p 2 × i = 1 9 i = p 1 + ( p 1 + p 2 ) × p 1 = p 1 × ( p 1 + 1 ) 2 \\ p_3 = \sum\limits_{i=100}^{999} p(i) \\ = \sum\limits_{i=1}^9 (\sum\limits_{j=0}^{99} p(100i + j)) \\ = \sum\limits_{i=1}^9 (p(100i) + \sum\limits_{j=1}^{99} p(100i + j)) \\ = \sum\limits_{i=1}^9 p(100i) + \sum\limits_{i=1}^9 (\sum\limits_{j=1}^{99} p(100i + j)) \\ = p_1 + \sum\limits_{i=1}^9 (i \times \sum\limits_{j=1}^{99} p(j)) \\ = p_1 + \sum\limits_{i=1}^9 (i \times (p_1 + p_2)) \\ = p_1 + p_2 \times \sum\limits_{i=1}^9 i \\ = p_1 + (p_1 + p_2) \times p_1 \\ = p_1 \times (p_1 +1)^2

So i = 1 999 p ( i ) = p 1 + p 2 + p 3 = 45 + ( 45 × 46 ) + 45 × ( 45 + 1 ) 2 = 45 × ( 1 + 46 + 4 6 2 ) = 45 × 2163 = 45 × 21 × 103 = 3 3 × 5 × 7 × 103 \sum\limits_{i=1}^{999} p(i) = p_1 + p_2 + p_3 \\ = 45 + (45 \times 46) + 45 \times (45 + 1)^2 \\ = 45 \times (1 + 46 + 46^2) \\ = 45 \times 2163 = 45 \times 21 \times 103 \\ = 3^3 \times 5 \times 7 \times 103

Chew-Seong Cheong
Nov 14, 2020

Note that p ( n ) p(n) can be defined as product of digits of number n n with all 0 0 digit replaced with 1 1 . Let S ( n ) = k = 1 n p ( k ) S(n) = \displaystyle \sum_{k=1}^n p(k) . Then we have:

S ( 999 ) = k = 1 999 p ( k ) = k = 1 9 p ( k ) + k = 10 99 p ( k ) + k = 100 999 p ( k ) = k = 1 9 k + k = 1 9 k ( 1 + 1 + 2 + + 9 ) + k = 100 999 p ( k ) 0 replaced with 1 = S ( 9 ) + S ( 9 ) ( 1 + S ( 9 ) ) + k = 1 9 p ( 100 k ) + k = 1 9 k S ( 99 ) Note that S ( 99 ) = S ( 9 ) ( S ( 9 ) + 2 ) = S ( 9 ) ( S ( 9 ) + 2 ) + S ( 9 ) + S ( 9 ) 2 ( S ( 9 ) + 2 ) = S ( 9 ) ( S ( 9 ) + 2 + 1 + S ( 9 ) ( S ( 9 ) + 2 ) ) and S ( 9 ) = k = 1 9 k = 9 ( 9 + 1 ) 2 = 45 = 45 ( 2163 ) = 3 3 5 7 103 \begin{aligned} S(999) & = \sum_{k=1}^{999} p(k) \\ & = \sum_{k=1}^9 p(k) + \sum_{k=10}^{99} p(k) + \sum_{k=100}^{999} p(k) \\ & = \sum_{k=1}^9 k + \sum_{k=1}^9 k(\red 1 + 1 + 2 + \cdots + 9) + \sum_{k=100}^{999} p(k) & \small \red{\text{0 replaced with 1}} \\ & = \blue{S(9) + S(9)(1+S(9))} + \sum_{k=1}^9 p(100k) + \sum_{k=1}^9 kS(99) & \small \blue{\text{Note that }S(99) = S(9)(S(9)+2)} \\ & = S(9)(S(9)+2) + S(9) + S(9)^2(S(9)+2) \\ & = S(9)(S(9)+2 + 1 + S(9)(S(9)+2)) & \small \blue{\text{and }S(9) = \sum_{k=1}^9 k = \frac {9(9+1)}2= 45} \\ & = 45 (2163) \\ & = 3^3\cdot 5 \cdot 7 \cdot 103 \end{aligned}

Therefore the greatest prime divisor of S ( 999 ) S(999) is 103 \boxed{103} .

Fletcher Mattox
Nov 14, 2020
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from numpy import prod
from sympy import factorint

def product(n):
    s = list(str(n))
    s = [i for i in s if i != '0']
    return prod([int(i) for i in s])

xsum = sum([product(n) for n in range(1, 1000)])
print(max(factorint(int(xsum), multiple=True)))

1
103

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...