Small is greater than large!

Find the sum of all integers n 999 n \leq999 such that sum of digits of 2 n 2^{n} > > sum of digits of 3 n + 1 3^{n+1} .


The answer is 75.

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.

5 solutions

Chew-Seong Cheong
May 14, 2015

I used the following Python coding.

There are only two values, n = 20 , 55 n = 20, 55\quad , therefore the required answer is 75 \boxed{75} .

Nice solution sir! I also used a similar code!

Harsh Shrivastava - 6 years, 1 month ago
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def sumDigits( n ):
    sum1 = 0
    while n:
        sum1 += n%10
        n /= 10
    return sum1

ans = 0    
for i in range(0,1000):
    sumDigits2 = sumDigits( 2**i )
    sumDigits3 = sumDigits( 3**(i+1) )
    if sumDigits2 > sumDigits3:
        ans += i

print ans        

ahahaha.. idol!!

Keil Cerbito - 6 years ago
Brock Brown
May 20, 2015

Python 2.7:

1
2
3
4
5
def digit_sum(n):
    return sum([int(i) for i in str(n)])
def goal(n):
    return digit_sum(2**n) > digit_sum(3**(n+1))
print "Answer:", sum([n for n in xrange(1000) if goal(n)])

Bill Bell
Jul 2, 2015

Exponentiation over and over again is expensive of computer cycles, and therefore to be avoided.

Arulx Z
Jul 2, 2015
1
2
3
4
5
6
def summ(n):
    return sum(int(x) for x in str(n))
tot = 0
for n in xrange(1, 1000):
    tot += n if summ(2**n) > summ(3**(n+1)) else 0
print tot

Moderator note:

Good, standard solution.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...