Explain in python programming

(x^n-1)/(x-1) = x^(n-1)+x^(n-2)+...+x+1

In python, we can calculate the expression (x^n-1)/(x-1) using a loop. Here's the step-by-step process to get the desired result:

1. Take the inputs x and n from the user.
```
x = int(input("Enter the value of x: "))
n = int(input("Enter the value of n: "))
```

2. Create a variable called `result` and initialize it to 0. This variable will store the cumulative sum of the terms in the equation.
```
result = 0
```

3. Run a loop from i = 0 to i = n-1 (inclusive). In each iteration, calculate x^i and add it to the `result` variable.
```
for i in range(n):
result += x ** i
```

4. Finally, divide `result` by (x-1) to get the final answer and print it.
```
final_result = result / (x - 1)
print(final_result)
```

The complete code will look like this:

```python
x = int(input("Enter the value of x: "))
n = int(input("Enter the value of n: "))

result = 0

for i in range(n):
result += x ** i

final_result = result / (x - 1)
print(final_result)
```

This code will calculate and print the value of (x^n-1)/(x-1) using the formula x^(n-1)+x^(n-2)+...+x+1.