Vorige Pagina About the Author

' Generates Magic Series of order 5
' Squares of Squares

' Tested with Office 2007 under Windows 7

Sub MgcLns5()

Dim a(48), a1(5)

y = MsgBox("Blocked", vbExclamation, "MgcLns5")
End

Sheets("Klad1").Select

n5 = 48

For j100 = 272 To 407	                  'Select Range

s2 = Sheets("nLns5").Cells(j100, 1).Value

For i1 = 1 To n5
    a(i1) = i1
Next i1

n10 = 0
For j1 = 1 To n5
a1(1) = a(j1)
For j2 = j1 + 1 To n5
a1(2) = a(j2)
For j3 = j2 + 1 To n5
a1(3) = a(j3)
For j4 = j3 + 1 To n5
a1(4) = a(j4)
For j5 = j4 + 1 To n5
a1(5) = a(j5)

s5 = a1(1) ^ 2 + a1(2) ^ 2 + a1(3) ^ 2 + a1(4) ^ 2 + a1(5) ^ 2
If s5 <> s2 Then GoTo 50

n9 = n9 + 1: n10 = n10 + 1
For i1 = 1 To 5
    Cells(n9, i1).Value = a1(i1)
Next i1
Cells(n9, 6).Value = n10
Cells(n9, 7).Value = s2

50 Next j5
40 Next j4
30 Next j3
20 Next j2
10 Next j1

Cells(j100, 10).Value = n9

Next j100

End Sub

Vorige Pagina About the Author