 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Integers and their sums of digits (Posted on 2017-03-13) Find all solutions of the system
s(x) + s(y) = x
x + y + s(z) = z
s(x) + s(y) + s(z) = y − 4,
where x, y and z are positive integers, and each of s(x), s(y) and s(z) denotes the sum of digits of x, y and z, respectively, in decimal notation.

 No Solution Yet Submitted by Ady TZIDON No Rating Comments: ( Back to comment list | You must be logged in to post comments.) computer solution | Comment 2 of 3 | ` x  y  z18 27 5018 36 68`

found by

DefDbl A-Z
Dim crlf\$

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For z = 5 To 10000
sodz = sod(z)
xplusy = z - sodz
For x = 1 To xplusy - 1
DoEvents
y = xplusy - x
sodx = sod(x): sody = sod(y)
If sodx + sody = x Then
If x + sodz = y - 4 Then
Text1.Text = Text1.Text & x & Str(y) & Str(z) & crlf
End If
End If
Next
Next

Text1.Text = Text1.Text & crlf & " 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

Edited on March 19, 2017, 11:38 am
 Posted by Charlie on 2017-03-19 11:38:14 Please log in:

 Search: Search body:
Forums (0)