The Ramanujan Search

HardAcc. 70.8%
+45 XP 25

The Hardy-Ramanujan Magic

A Taxicab number is an integer that can be expressed as the sum of two cubes in two different ways ($a^3 + b^3 = c^3 + d^3$).

The Assignment

Your function receives a parameter limit.

  1. Use triple-nested loops to iterate through potential cubes $a, b, c, d$.
  2. To avoid duplicates, ensure $a < b$ and $c < d$ and $a < c$.
  3. If $a^3 + b^3$ equals $c^3 + d^3$ and the result is less than or equal to limit:
    • Print: "target = a^3 + b^3 = c^3 + d^3"

01EXAMPLE 1

Inputlimit = 2000
Output1729 = 1^3 + 12^3 = 9^3 + 10^3

Explanation: The first Taxicab number.

Constraints

  • Use nested loops to find the pairs.
  • Correct output formatting.
MathLoopsOptimization
JavaScript
Loading...
2 Hidden

Input Arguments

limit2000

Expected Output

1729 = 1^3 + 12^3 = 9^3 + 10^3

Click RUN to test your solution