我是編程新手(Python是我的第一語言),但我喜歡設計算法。我目前正在研究一個方程組(整數),我找不到任何關於解決我的特定問題的參考。在Python中求解困難(多項式?)方程
讓我解釋一下。
我有一個公式(一個測試,如果你願意):
raw_input == [(90*x + a) * y] + z
其中a是某個常數。
我的問題是,變量z的計數方式非常類似於斐波那契數列,而變量x是z的步長。所以我的意思是(對斐波那契數列)是在z序列的第一項中x = 0,在z序列的第二項中x = 1。我需要求解y。
用於確定荷比確切過程如下
where c and d are constants:
#at x = 0
temp = (c+(90*x)) * (d+(90*x))
temp/90 = z(0)
#at x = 1
new_temp = (c+(90*x)) * (d + (90*x))
new_temp/90 = z(1)
#for all the rest of the values of z (and x), use:
j = z(@ x=1) - z(@ x=0)
k = j + 180
l = z(@ x=1) + k
print "z(@ x=1) - z(@ x=0) = j"
print "j + 180 = k"
print "k + z(1) = l"
repeat until z > raw_input
this creates the spread of z values by the relation:
j = z(@ x=n) - z(@ x=n-1)
k = j + 180
l = k + z(@ x = n)
我需要通過掃描(跳過)的值z與< x到測試y的一個整數溶液的狀態。
這看起來可能嗎?
一個丟番圖方程,eh?請參閱維基百科上的[Bezout's identity](http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity)。使用'range'遍歷一組值。如果你需要知道如何使用它,請在python.org上查找它。 – 2012-02-12 03:24:57