← run

lcb-0082

1.000
4/4 tests· algorithms

Proposed solution

```python
# solution.py
import sys

def calculate_geometric_series(N, M):
    X = sum(N**i for i in range(M + 1))
    return X if X <= 10**9 else 'inf'

if __name__ == "__main__":
    input_data = sys.stdin.read().strip()
    N, M = map(int, input_data.split())
    result = calculate_geometric_series(N, M)
    print(result)
```

Test output (stdout)

....                                                                     [100%]
4 passed in 0.06s
System prompt
You are an expert programmer. Solve the task exactly as specified. Output your solution as fenced code blocks using the required file name(s) and the exact function/type signatures requested. Prefer correctness; do not include prose outside code unless asked.