All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Ternary Sum Travail (Posted on 2014-10-14)
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.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 1 of 2
DefDbl A-Z
Dim crlf\$

ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf\$ = Chr(13) + Chr(10)
Form1.Visible = True

DoEvents

For n = 1 To 2014
b3\$ = base\$(n, 3)
tot = 0
For i = 1 To Len(b3\$)
tot = tot + Val(Mid(b3\$, i, 1))
Next
If tot >= 7 Then gte7 = gte7 + 1
Next
Text1.Text = Text1.Text & gte7 & Str(gte7 / 2014) & crlf

Text1.Text = Text1.Text & crlf & " done"
End Sub

Function base\$(n, b)
v\$ = ""
n2 = n
Do
d = n2 Mod b
n2 = n2 \ b
v\$ = Mid("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", d + 1, 1) + v\$
Loop Until n2 = 0
base\$ = v\$
End Function

finds

1124 .558093346573982

meaning 1124 out of the 2014 numbers have G(n) >= 7 for a probability of approximately .558093346573982 or exactly 562/1007.

 Posted by Charlie on 2014-10-14 14:55:57

 Search: Search body:
Forums (0)