You will build the polynomial through given points with Lagrange's formula, and count binomial coefficients in steps of three in two ways.
The idea. The value at of the polynomial through is . Use Fraction so the answers are exact. The sum of over can be found directly with math.comb, or from , and .
Your tasks.
lagrange(points, x). Return the exact value at x.direct(n, r). Return the sum of comb(n, k) for k with k % 3 == r.filtered(n, r). Return the rounded real part of .Run your code once to unlock the worked solution.
Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…