Find two
positive integers X and Y, with X ≤ Y, that satisfy this set of simultaneous relationships:
lcm(X, Y)
 = 1785, and:
gcd(X, Y)
X + Y = 2014
efDbl AZ
Dim crlf$
Private Sub Form_Load()
ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
Sum = 2014
For x = 1 To Sum / 2
y = Sum  x
l = lcm(x, y)
g = gcd(x, y)
If l / g = 1785 Then
Text1.Text = Text1.Text & x & Str(y) & " " & lcm(x, y) & Str(gcd(x, y)) & crlf
End If
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function gcd(a, b)
x = a: y = b
Do
q = Int(x / y)
z = x  q * y
x = y: y = z
Loop Until z = 0
gcd = x
End Function
Function lcm(a, b)
lcm = a * b / gcd(a, b)
End Function
finds
x=399 y=1615 LCM=33915 GCD=19
LCM/GCD = 1785 as required
LCM/GCD is of course also x * y / GCD ^ 2
1785 = 3 * 5 * 7 * 17
and
x = 3 * 7 * 19 and y = 5 * 17 * 19
so an analytic method might have employed splitting the factors of 1785 into the two separate x and y and adding a common factor identically to each, so that the sum of 2014 would be reached.

Posted by Charlie
on 20140927 15:17:56 