Last active
May 31, 2018 14:03
-
-
Save bastienapp/00bdbce4df211a88ad76d9a03507e732 to your computer and use it in GitHub Desktop.
Build a pile of Cubes
This file contains hidden or 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
public class ASum { | |
public static long findNb(long m) { | |
long total = 0; | |
long n = 0; | |
for (n = 1; total < m; n++) { | |
total += (long) Math.pow(n, 3); | |
} | |
return total == m ? n - 1 : -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment