链表
\[f(x)=a_{0}+a_{1} x+\cdots+a_{n-1} x^{n-1}+a_{n} x^{n}
\]
input:i,\(x_i\),a[\(\dots\)]--List
a=[3,43,54,22]
def func(x):
for m in range(0,3):
p=a[m]*x**m
return x
func(3)
3
\[f(x)=a_{0}+x\left(a_{1}+x\left(\cdots\left(a_{n-1}+x\left(a_{n}\right)\right) \cdots\right)\right)
\]
这里要先解决一个逆序的问题:
利用range函数本身的性质
new =[]
for i in range(5,0,-1):
new.append(i)
print(new)
[5, 4, 3, 2, 1]
a=[3,43,54,22]
def func(x):
for m in range(3,0,-1):
p=a[3]
p=x*p+a[m-1]
return x
func(3)