Skip to content

Instantly share code, notes, and snippets.

View abscosmos's full-sized avatar

Joshua abscosmos

View GitHub Profile
@abscosmos
abscosmos / series_rearrangement.py
Last active October 31, 2025 15:29
A script based on the Riemann rearrangement theorom that reorders the terms in a conditionally convergent infinite sum to converge to a specific number.
import sympy as sp
def count_signs(seq):
counts = []
current_sign = 1 if seq[0] > 0 else -1
current_count = 1
for i in range(1, len(seq)):
if (seq[i] > 0 and current_sign == 1) or (seq[i] < 0 and current_sign == -1):
current_count += 1