total_attempts = 256*256*256 successful_attempts = 0 for a in range(0, 256): for b in range(0, 256): for c in range(0, 256): if a + b + c > 300: successful_attempts += 1 print(f"Iterations: {total_attempts}") print(f"Valid sums: {successful_attempts}") print(f"Probability: {successful_attempts / total_attempts}")