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

Home > Probability
Ternary Sum Travail (Posted on 2014-10-14) Difficulty: 3 of 5
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.)
Solution computer solution | Comment 1 of 2
DefDbl A-Z
Dim crlf$

Private Sub Form_Load()
 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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information