Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def tupleInList(fx, x=[]):
- for i in range(len(fx)):
- x.append(i+1)
- return zip(x, fx)
- def solve(s):
- return R.lagrange_polynomial(s)
- def nextSeq(l, f):
- exec('x = ' + str(l+1))
- exec('f = ' + str(f).replace('^', '**'))
- return f
- if __name__ == '__main__':
- R = PolynomialRing(QQ, 'x')
- fx = [1, 4, 9, 16, 25]
- s = tupleInList(fx)
- print s
- f = solve(s)
- l = len(fx)
- print 'Formula: ', f
- print nextSeq(l, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement