Changed test generation function

This commit is contained in:
Dmitriy Shishkov 2021-10-31 16:27:27 +03:00
parent 5311f70746
commit 7efb7133f6
No known key found for this signature in database
GPG Key ID: 14358F96FCDD8060
2 changed files with 15 additions and 1 deletions

View File

@ -7,5 +7,19 @@ except:
print(n)
def f(x: int) -> int:
"""
f(x) = sum with i from 0 to n-1 (i+1)*x^i
E.g. f(x) = 5x^4 + 4x^3 + 3x^2 + 2x + 1
"""
res: int = 0
for i in range(n):
res += (i+1) * pow(x, i)
return res
for i in range(n):
print(i, -i if i % 2 == 0 else i)
print(i, f(i))

View File