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

Home > Numbers > Sequences
LCM and GCD Sequence (Posted on 2016-04-29) Difficulty: 3 of 5
Find all pairs (X,Y) of positive integers such that:
gcd(X,Y), lcm(X,Y)-1 and XY (in this order) are in arithmetic sequence.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts probable solution (spoiler) Comment 1 of 1
DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 
 crlf = Chr$(13) + Chr$(10)
 
 l10 = Log(10)
 For tot = 3 To 9999999
   For x = 1 To tot / 2
    DoEvents
     y = tot - x
     lpwr = Log(x) * y / l10
     If lpwr < 16 Then
       p = Int(10 ^ lpwr + 0.5)
       g = gcd(x, y)
       lcm = x * y / g
       If p + g = 2 * (lcm - 1) Then
         Text1.Text = Text1.Text & x & Str(y) & "    " & g & Str(lcm - 1) & Str(p) & crlf
       End If
     End If
     h = y: y = x: x = h
     lpwr = Log(x) * y / l10
     If lpwr < 16 Then
       p = Int(10 ^ lpwr + 0.5)
       g = gcd(x, y)
       lcm = x * y / g
       If p + g = 2 * (lcm - 1) Then
         Text1.Text = Text1.Text & x & Str(y) & "    " & g & Str(lcm - 1) & Str(p) & crlf
       End If
     Else
       Exit For
     End If
    h = y: y = x: x = h
   Next
 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

finds only

x y    sequence
1 2    1 1 1
3 1    1 2 3
3 2    1 5 9


  Posted by Charlie on 2016-04-29 11:30:46
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (24)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information