Compute 2018

Find the highest 9 9 -digit number a b c d e f g h i \overline{abcdefghi} with distinct non-zero digits a , b , c , d , e , f , g , h , a, b, c, d, e, f, g, h, and i , i, such that a ( b + c ( d + e ( f + g ( h + i ) ) ) ) = 2018. a(b+c(d+e(f+g(h+i)))) = 2018. and that a , c , e , a, c, e, and g g are not equal to 1 1 .


The answer is 298546371.

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

Giorgos K.
May 15, 2018

using M a t h e m a t i c a Mathematica

FromDigits/@Select[Permutations@Range@9,#[[1]](#[[2]]+#[[3]](#[[4]]+#[[5]](#[[6]]+#[[7]](#[[8]]+#[[9]]))))==2018&]

returns ALL possible numbers

{128754369,128754396,128934756,128934765,135798624,135798642,164782539,164782593,183492657,183492675,213847569,213847596,214936578,214936587,245968317,245968371,287536419,287536491,295864713,295864731,298546317,298546371}

so we start searching for the highest that meets the criteria
starting from the last one and... it is indeed the right one!

298546371 \boxed{298546371}

Zeeshan Ali
May 15, 2018
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import itertools # https://docs.python.org/2/library/itertools.html#itertools.permutations
import numpy as np # http://www.numpy.org/

# set of all the possible 9 non-zero-digit numbers in decending order
permutations = list(itertools.permutations([i for i in range(9, 0, -1)], 9))

# for every p = (a, b, c, d, e, f, g, h, i) in above set
for p in permutations:
    # if all elements in p are unique
    if len(np.unique(p)) == 9:
        # if a*(b+c*(d+e*(f+g*(h+i)))) equals 2018
        if p[0]*(p[1]+p[2]*(p[3]+p[4]*(p[5]+p[6]*(p[7]+p[8])))) == 2018:
            # print the elements or digits of that number 'p'
            print (p)
            # since the p's in permutations are in decending order therefore the first one satisfying
            # the condition is the larget such number, hence break (i.e. stop further search)
            break

(2, 9, 8, 5, 4, 6, 3, 7, 1)

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...