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

 Distinct sod (Posted on 2014-12-09)
A, B and C are three positive integers satisfying: A+B = 132 and B+C = 278.

How many distinct values of sod(A) + sod(C) are possible?

** sod(n) is the sum of the digits in the base ten expansion of n.

 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 1
Twenty possible sums of sod's exist, from 10 to 29:

`  10  1  11 71  12  3  13  6  14  6  15  8  16  9  17 11  18 11  19 13  20 71  21 12  22 10  23  8  24  7  25  5  26  4  27  3  28  1  29 19`

The numbers indicate how many value sets (dependent on b) result in the given number for the total of the two sod's.

DefDbl A-Z
Dim crlf\$
Dim sumsod(54)

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

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

sumPlus = 132 + 278
For b = 1 To sumPlus - 131
a = 132 - b: c = 278 - b
tot = sod(a) + sod(c)
sumsod(tot) = sumsod(tot) + 1
Next b
For i = 1 To 54
If sumsod(i) > 0 Then
Text1.Text = Text1.Text & mform(i, "###0") & mform(sumsod(i), "##0") & crlf
ct = ct + 1
End If
Next
Text1.Text = Text1.Text & ct & crlf

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

Function sod(n)
s\$ = LTrim(Str(n))
tot = 0
For i = 1 To Len(s\$)
tot = tot + Val(Mid(s\$, i, 1))
Next
sod = tot
End Function

 Posted by Charlie on 2014-12-09 11:23:28

 Search: Search body:
Forums (0)