我是编程新手(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