G(n) represents the sum of the digits of the ternary representation of n, where n is a positive integer randomly chosen from 1 (base ten) to 2014 (base ten) inclusively.

Determine the probability that G(n) ≥ 7.

Luckily enough, it is 2014 and not 20140, so straightforward
bean-counting is feasible, albeit quite tedious.

I have decided to post it after I saw
that my result does not contradict computer findings.

Solution:

There are 3^7 (=2187 )ternary 7-digit numbers between
0000000 and 2222222 inclusive.

The average G (=sum of digits) is 7 and clearly there are as
many numbers with G>7 as there are numbers with G<7 ( consider 2-s complement: - to any number with G=7-K
corresponds exactly one number with G=7+K ) .

So once we know the quantity of numbers with G=7, say Q, then the quantity of numbers with G>7

Will be y=(2187-Q)/2.

Let see how many numbers (still up to 2187) have G=7:

All ones ……………………………..… 1 way to do it

one 2, one zero, 5 ones…………..7*6=42 ways

two 2’s two zeroes,3 ones ……..21*10= 210 ways

three 2’s three zeroes,1 one ……..35*4= 140 ways

Ergo Q=393 and our
number y=(2187-393)/2=897

From this number we have to deduce the quantity falling in the range between 2202122(2015 dec) to 2222222 (2186) i.e.
to examine 172 numbers for their s.o.d.

Instead of counting the numbers with G>7 let us show that
only 6 numbers over 2014 yield G=6
or less.

Indeed those numbers are
2210000, 2210001, 2210010, 2210100, 2211000 and 2220000.

So the quantity of numbers with G=7 in the range 0 to 2014
is 393-(172-6)=393-166=233

The total of 233 and 897
is 1124 and the desired probability p=1124/2014=.558

**Answer: p=0.558**