Skip to content

Instantly share code, notes, and snippets.

@christianp
Created February 28, 2015 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianp/2db3938c8c2427810819 to your computer and use it in GitHub Desktop.
Save christianp/2db3938c8c2427810819 to your computer and use it in GitHub Desktop.
Smallest integer-radius sphere whose volume is within 0.0001 of an integer - https://twitter.com/wacnt/status/571459946644029440
from itertools import count
from mpmath import pi,floor,ceil,mp
for r in count(1):
v = pi*mp.mpf(r)**3 * 4/3
d = min(v-floor(v), ceil(v)-v)
if d<0.00001:
print(r)
break
@christianp
Copy link
Author

Output is 12352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment