 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Cinq Digit Choice (Posted on 2014-09-22) A five digit positive integer N without a leading zero is selected at random.

Determine the probability that the sum of the first digit, third digit and fifth digit of N is equal the product of its second digit and fourth digit.

 No Solution Yet Submitted by K Sengupta No Rating Comments: ( Back to comment list | You must be logged in to post comments.) computer solution (spoiler) Comment 1 of 1
DefDbl A-Z
Dim crlf\$

Function mform\$(x, t\$)
a\$ = Format\$(x, t\$)
If Len(a\$) < Len(t\$) Then a\$ = Space\$(Len(t\$) - Len(a\$)) & a\$
mform\$ = a\$
End Function

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 = 10000 To 99999
s\$ = LTrim(Str(n))
prod = Val(Mid(s\$, 2, 1)) * Val(Mid(s\$, 4, 1))
Sum = Val(Mid(s\$, 1, 1)) + Val(Mid(s\$, 3, 1)) + Val(Mid(s\$, 5, 1))
ct = ct + 1
If Sum = prod Then
goodct = goodct + 1
Text1.Text = Text1.Text & n & Str(goodct) & Str(ct) & mform(goodct / ct, "#0.0000000") & crlf
DoEvents
End If
Next
Text1.Text = Text1.Text & Str(goodct) & Str(ct) & mform(goodct / ct, "#0.0000000") & crlf

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

finds

1738 90000 0.0193111

which is 1738 such numbers out of the 90000 numbers in the range for a probability of 1738/90000 = 869/45000 = 0.019311111....

An analytic method would examine the 9*8/2=36 possible products of different digits and the 9 possible products of equal digits that could result in a positive sum, and see how many ways three single-digit numbers, the first of which can't be zero, can add up to the respective products. Any products greater than 27 could be ignored of course.

Needing consideration are:

1*1
1*2
1*3
1*4
1*5
1*6
1*7
1*8
1*9

2*2
2*3
2*4
2*5
2*6
2*7
2*8
2*9

3*3
3*4
3*5
3*6
3*7
3*8
3*9

4*4
4*5
4*6

5*5

Sets of digits adding to the products of the same integer (i.e., squares) count only once, while those of unequal digits count twice, Completion is "left as an exercise for the reader".

 Posted by Charlie on 2014-09-22 16:29:18 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 - 2021 by Animus Pactum Consulting. All rights reserved. Privacy Information