It is the smallest number expressible as a sum of two cubes in two different ways.
# Function to check if a number can be expressed as the sum of two cubes in two different ways
def is_special_number(n):
# Dictionary to store sums of cubes
cube_sums = {}
# Iterate through possible pairs of numbers
for a in range(1, int(n ** (1/3)) + 1):
for b in range(a, int(n ** (1/3)) + 1):
cube_sum = a**3 + b**3
if cube_sum in cube_sums:
cube_sums[cube_sum].append((a, b))
else:
cube_sums[cube_sum] = [(a, b)]
# Check for the number of ways to express n as the sum of two cubes
if n in cube_sums and len(cube_sums[n]) > 1:
return cube_sums[n]
else:
return None
# Test the function with the number 1729
number = 1729
result = is_special_number(number)
if result:
print(f"The number {number} can be expressed as the sum of two cubes in two different ways:")
for pair in result:
print(f"{number} = {pair[0]}^3 + {pair[1]}^3")
else:
print(f"The number {number} cannot be expressed as the sum of two cubes in two different ways.")
To embed this project on your website, copy the following code and paste it into your website's HTML: