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

 (sod(x))^2 = x+2 (Posted on 2011-01-26)
Determine the probability that for a base ten positive integer x chosen at random from 1 to 9999 inclusively, this relationship is satisfied: (sod(x))2 = x+2, where sod(n) denotes the sum of the digits in the base ten representation of n.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 solution using QuickBasic | Comment 2 of 3 |

denCt = 0
Do
ix = InStr(l\$, ",")
If ix Then
denCt = denCt + 1: l\$ = Mid(l\$, ix + 1)
Else
denCt = denCt + 1
End If
Loop Until ix = 0
ReDim den(denCt)
l\$ = txtDenom.Text
denCt = 0
Do
ix = InStr(l\$, ",")
If ix Then
denCt = denCt + 1: den(denCt) = Val(Left(l\$, ix - 1))
l\$ = Mid(l\$, ix + 1)
Else
denCt = denCt + 1: den(denCt) = Val(l\$)
End If
Loop Until ix = 0

finds

2
23
62
119
194
287
398
7             7.000700070007001D-04       1428.428571428571

That is the list of 7 integers satisfying the relationship, and the probability of 0.00070007..., or 1/1428.428571428571....

 Posted by Charlie on 2011-01-26 15:37:33

 Search: Search body:
Forums (0)