A number theory problem by Akshat Sharda

Given a positive integer n n , let P ( n ) P(n) be the product of the nonzero digits of n n .

If n n has only one digit, then P ( n ) P(n) is equal to that digit.

S = P ( 1 ) + P ( 2 ) + + P ( 999 ) S = P(1)+ P(2)+\ldots+P(999)

Find the largest prime factor of S S ?


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.

2 solutions

Rajdeep Brahma
Mar 25, 2018

P (1) to P (10) summation is 46. P (11) to P (20) is 46×1. P (21) to P (30) is 46×2....See a pattern? So P (1) to P (99) will be 46×(1+1+2....+9)=46×46-1 P(100) to P (199)=46×46 too P (200) to P (299)=46×46×2 (Since a factor 2 comes in hundred place) Similarly,P (900) to P (999) is 46×46×9 The reqd sum will be 46×46×46-1....have 103 as highest factor... hence the answer.

Computer science solution xD

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#function to find no. of factors
def nf(n):
    i=1
    s=0
    while i <= n:
        if n % i == 0:
            s += 1
        i += 1
    return s
# function to check primality
def isprime(n):
    if(n%2==0) & (n!=2):
        return 0
    else:
        if nf(n) == 2:
            return 1
        else:
            return 0
#function to evaluate product of the non-zero digits of a number
def p(n):
    p=1
    while n > 0:
        if n % 10 != 0:
            p *= n % 10
            n -= n % 10
        n /= 10
    return p

i=1
s=0
while i <= 999:
    s += p(i)
    i += 1
maxprime=1
i=1
while i <= s:
    if (s % i == 0) & (isprime(i)==1) & (i > maxprime):
        maxprime = i
    i += 1
print(maxprime)

Takes some time to show the output though.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...