Skip to content

Instantly share code, notes, and snippets.

@agawley

agawley/main.py Secret

Last active June 29, 2026 08:56
Show Gist options
  • Select an option

  • Save agawley/33e0c3807e66b545b07f6361dc92a86b to your computer and use it in GitHub Desktop.

Select an option

Save agawley/33e0c3807e66b545b07f6361dc92a86b to your computer and use it in GitHub Desktop.
Cassidoo 2026-06-29
from math import floor, log2
def getBits(val):
if val == 0:
return 1
return floor(log2(val)) + 1
def sumBits(val):
sum = 0
for a in range(val):
sum += getBits(a)
return sum / val
print(sumBits(6))
print(sumBits(12))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment