All problems
Z-Transform of Geometric Sequence
Problem
The z-transform of x[n] = a^n for n >= 0 is X(z) = sum of a^n * z^(-n) = z / (z - a), converging for |z| > |a|.
Given a and z with z != a, return X(z).
Hint
This is a geometric series in a / z; sum it in closed form.
Test cases
case 1
in: [0.5,2]
expected: 1.3333333333333333
case 2
in: [0,3]
expected: 1
case 3
in: [2,4]
expected: 2
case 4
in: [0.5,-1]
expected: 0.6666666666666666
Starter codePython
def z_transform_geometric(a, z):
# Your code here
pass4 test cases · run your code against them in the editor