Created
June 3, 2024 05:23
-
-
Save secemp9/074a375051b89ea1e85ac2acf68e3ba0 to your computer and use it in GitHub Desktop.
infinite series example in python code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sum_series(n): | |
| total_sum = 0 | |
| for k in range(1, n + 1): | |
| total_sum += 1 / (2 ** k) | |
| return total_sum | |
| n = 1000 # Number of terms to approximate the sum | |
| result = sum_series(n) | |
| print("Approximate sum of the series:", result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment