Joke number

Smith Numbers are composite numbers n n such that sum of digits of n = n= sum of digits of prime factors of n n (counted with multiplicity).

For example : 58 = 2 × 29 58=2 \times 29 and 5 + 8 = 2 + 2 + 9 = 13 5+8=2+2+9=13 . so 58 is a Smith number.

Find the first number n n such that n , n + 1 , n + 2 , n + 3 n,n+1,n+2,n+3 are smith numbers


The answer is 4463535.

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.

1 solution

Bill Bell
Jan 27, 2016
 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
from sympy import factorint
from sortedcontainers import SortedList
import pyprimesieve

def isSmithNumber(n, show=False):
    if n in primes:
        return False
    v=factorint(n)
    left=sum(map(int,list(''.join([v[i]*str(i) for i in v])))) 
    right=sum(map(int,list(str(n))))
    if show:
        print v
        print map(int,list(''.join([v[i]*str(i) for i in v])))
        print map(int,list(str(n)))
    return left==right

primes=SortedList(pyprimesieve.primes(5000000))

n=0
count=0
while True:
    if isSmithNumber(n):
        count+=1
        if count==4:
            print n-3, isSmithNumber(n-3,True)
            break
    else:
        count=0
    n+=1

And very reassuring to find that my result agreed with what's available on oeis.org. :)

my answer is coming out 17837.

gurdeep singh - 4 years ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...