Created
January 30, 2018 05:03
-
-
Save mariomelchor/9d99c241706b09feaf09d6eeead73d2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cubeSumSearch(1729); | |
function cubeSumSearch(n) { | |
var total = n; | |
for(var i = 0; i <= n; i++){ | |
for(var j = i; j <= n; j++){ | |
var sum = Math.pow(i, 3) + Math.pow(j, 3); | |
if( sum === total ){ | |
console.log('-------------------------'); | |
console.log(`${Math.pow(i, 3)} + ${Math.pow(j, 3)} = ${sum}`); | |
console.log(`${i}^3 + ${j}^3 = ${sum}`); | |
console.log('-------------------------'); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment