過去ログ

???
Option Explicit
Sub Macro1()
Sheets("Sheet1").Select
Cells(1, 1).Value = 0
Dim A As Integer
Dim B As Integer
Dim C As Integer
For A = 1 To 72
For B = 1 To 144
If LCM(A, B) = 72 Then
For C = 1 To 144
If LCM(B, C) = 144 And LCM(C, A) = 144 Then
Cells(1, 1).Value = Cells(1, 1).Value + 1
Cells(Cells(1, 1).Value, 2).Value = A
Cells(Cells(1, 1).Value, 3).Value = B
Cells(Cells(1, 1).Value, 4).Value = C
Range("B" & Cells(1, 1).Value).Select
End If
Next C
End If
Next B
Next A
Range("A1").Select
End Sub
Private Function GCM(ByVal x As Integer, ByVal y As Integer) As Integer
If y = 0 Then
GCM = x
Else
GCM = GCM(y, x Mod y)
End If
End Function
Private Function LCM(ByVal x As Integer, ByVal y As Integer) As Integer
LCM = x * y / GCM(x, y)
End Function
   7月2日(木) 13:21:56     34745

過去問題一覧へ戻る