from math import floor def next_b(b_prev): b = floor(b_prev) * (b_prev - floor(b_prev) + 1) return b def euler_751(): min_found = 2 theta_str_orig = "2." while len(theta_str_orig) < 26: for n in range(min_found, 1000): theta_str_new = str(theta_str_orig) + str(n) b = float(theta_str_new) theta_str = theta_str_new.replace("2.", "") while theta_str != "": b = next_b(b) a_str = str(floor(b)) # print(a_str, theta_str) if theta_str.startswith(a_str): theta_str = theta_str.replace(a_str, "", 1) else: break if theta_str == "": theta_str_orig = theta_str_new break return theta_str_orig if __name__ == "__main__": solution = euler_751() print("e751.py: " + str(solution)) assert solution == "2.223561019313554106173177"