割り算
a(5)*x^5+a(4)*x^4+a(3)*x^3+a(2)*x^2+a(1)*x+a(0)
=(x^2+b(1)*x+b(0))*(c(3)*x^3+c(2)*x^2+c(1)*x+c(0))
となるようにb(1),b(0)の値を変化させてc(k)の値を求めたいのですが、うまくいきません。どこかおかしい点がありましたら、ご指摘お願いします。
Sub gojisiki()
Dim i, j, x, y As Long
Dim a(10), b(10), c(10), d(10), e(10), f(10), g(10) As Long
For j = 1 To 6
a(6 - j) = Cells(2, j)
Next
For x = -500 To 500
b(1) = x
For y = -500 To 500
b(0) = y
For j = 5 To 2 Step -1
c(j - 2) = a(j)
For k = 1 To 0 Step -1
d(k) = c(j - 2) * b(k)
a(j - 2 + k) = a(j - 2 + k) - d(k)
Next
Next
If a(1) = 0 And a(0) = 0 Then GoTo tugi
Next
Next
tugi:
For j = 5 To 2 Step -1
Cells(3, 6 - j) = c(j - 2)
Next
Cells(4, 1) = b(1)
Cells(4, 2) = b(0)
End Sub
お礼
ありがとうございました。