Basic-benchmark-experiment/Python/code_cycle.py

13 lines
373 B
Python

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}")