|
▼cosuke さん:
作ってみました。
初めにa,b,cの大小関係を逆に考えていたので出力の並びが良くないですが
一応リストアップできていると思います。
変数lastで検討数を調整できるようにしましたがn+1の場合必要なさそうです。
Sub test()
Dim a As Long, b As Long, c As Long, d As Long, n As Long
Dim a1 As Long, b1 As Long, c1 As Long
Dim last As Long
Dim i As Long
last = 100
i = 1
Cells.ClearContents
Cells(1, 1).Value = "a"
Cells(1, 2).Value = "b"
Cells(1, 3).Value = "c"
Cells(1, 4).Value = "n"
Cells(1, 5).Value = "n+1"
Cells(1, 6).Value = "(n+1)/a"
Cells(1, 7).Value = "(n+1)/b"
Cells(1, 8).Value = "(n+1)/c"
Cells(1, 9).Value = "和"
For c = 1 To last - 3
For b = c + 1 To last - 2
For a = b + 1 To last - 1
d = (a * b + b * c + c * a)
If (a * b * c - d) = 0 Then
ElseIf d Mod (a * b * c - d) = 0 Then
n = d / (a * b * c - d)
If n > a And (n + 1) Mod a = 0 And (n + 1) Mod b = 0 _
And (n + 1) Mod c = 0 Then
i = i + 1
a1 = (n + 1) / a
b1 = (n + 1) / b
c1 = (n + 1) / c
'If n > a Then
Cells(i, 1).Value = a
Cells(i, 2).Value = b
Cells(i, 3).Value = c
Cells(i, 4).Value = n
Cells(i, 5).Value = n + 1
Cells(i, 6).Value = a1
Cells(i, 7).Value = b1
Cells(i, 8).Value = c1
Cells(i, 9).Value = a1 + b1 + c1
End If
End If
Next a
Next b
Next c
End Sub
>返答ありがとうございます。
>x+y+zは1ではないですね。
>
>例えば(a,b,c,N)=(6,4,2)のとき、x+y+z=11/12です。
|
|