DefDbl A-Z
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
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) GCD
200 40100 40501 401
601 361301 362504 401
1002 1004104 1006109 401
1403 1968509 1971316 401
1804 3254516 3258125 401
2205 4862125 4866536 401
2606 6791336 6796549 401
3007 9042149 9048164 401
...
95237 9070086269 9070276744 401
95638 9146627144 9146818421 401
96039 9223489621 9223681700 401
96440 9300673700 9300866581 401
96841 9378179381 9378373064 401
97242 9456006664 9456201149 401
97643 9534155549 9534350836 401
98044 9612626036 9612822125 401
98445 9691418125 9691615016 401
98846 9770531816 9770729509 401
99247 9849967109 9850165604 401
99648 9929724004 9929923301 401
|
Posted by Charlie
on 2014-10-12 14:17:06 |