Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
A recursive approach solution in Speedy category for Sum of Distinct Cubes by Guest_5a80b5eb
from math import cbrt, floor
from functools import cache
@cache
def sum_of_cubes(n: int) -> list[int] | None:
for m in range(floor(cbrt(n)), 0, -1):
r = n - m**3
if r == 0:
return [m]
s = sum_of_cubes(r)
if s:
s = [m, *s]
if len(s) == len(set(s)):
return s
return None
Jan. 26, 2026