 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Four Digit Trial (Posted on 2014-06-05) N is a 4-digit positive integer such that the sum of the four digits of N equals the product of the first two digits of N and also equals the product of the last two digits of N.

Find all N's and prove there are no others.

 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 3
DefDbl A-Z
Dim crlf\$

Text1.Text = ""
crlf\$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents

For n = 1000 To 9999
ns\$ = LTrim(Str(n))
p1 = Val(Mid(ns\$, 1, 1)) * Val(Mid(ns\$, 2, 1))
p2 = Val(Mid(ns\$, 3, 1)) * Val(Mid(ns\$, 4, 1))
If p1 = p2 Then
s = sod(n)
If s = p1 Then
Text1.Text = Text1.Text & n & crlf
End If
End If

Next

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

finds

3636
3663
4444
6336
6363

It checks all four-digit numbers.

 Posted by Charlie on 2014-06-05 16:41:56 Please log in:

 Search: Search body:
Forums (0)