```
""" find taxi-cab numbers which can be expressed as sum of cubes exactly two ways """
from collections import defaultdict
n = 1000000
qubes = [y**3 for y in range(int(n**(1/3))+1)]
ramanujan = defaultdict(int)
for ind, a in enumerate(qubes):
for b in qubes[ind:]:
if a + b > n: break
ramanujan[a+b] += 1
print(sorted(n for n in ramanujan if ramanujan[n] == 2))
```

About the Author

**Are you able to help answer this sponsored question?**

Questions asked by members who have earned a lot of community kudos are featured in order to give back and encourage quality replies.

Recommended Topics