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

 Greatest GCD (Posted on 2014-10-12)
The sequence {S(n)} is defined by the relationship: S(n) = 100 + n2, whenever n is a positive integer.

If G(n) = gcd(S(n), S(n+1)), then find the maximum value of G(n).

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer exploration | Comment 1 of 5
DefDbl A-Z
Dim crlf\$

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

DoEvents

For n = 1 To 100000
If gcd(s(n), s(n + 1)) > 1 Then
Text1.Text = Text1.Text & n & Str(s(n)) & Str(s(n + 1)) & "    " & Str(gcd(s(n), s(n + 1))) & crlf
DoEvents
End If
Next

Text1.Text = Text1.Text & crlf & maxlvl & Str(uct) & " done"
End Sub

Function s(n)
s = 100 + n * n
End Function

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 the only GCD > 1 is 401 as in:

`n    S(n)    S(n+1)      GCD200  40100   40501       401601  361301  362504      4011002 1004104 1006109     4011403 1968509 1971316     4011804 3254516 3258125     4012205 4862125 4866536     4012606 6791336 6796549     4013007 9042149 9048164     401...95237 9070086269 9070276744     40195638 9146627144 9146818421     40196039 9223489621 9223681700     40196440 9300673700 9300866581     40196841 9378179381 9378373064     40197242 9456006664 9456201149     40197643 9534155549 9534350836     40198044 9612626036 9612822125     40198445 9691418125 9691615016     40198846 9770531816 9770729509     40199247 9849967109 9850165604     40199648 9929724004 9929923301     401`

 Posted by Charlie on 2014-10-12 14:17:06

 Search: Search body:
Forums (0)