Skip to content

Instantly share code, notes, and snippets.

@bastienapp
Last active May 31, 2018 14:03
Show Gist options
  • Save bastienapp/00bdbce4df211a88ad76d9a03507e732 to your computer and use it in GitHub Desktop.
Save bastienapp/00bdbce4df211a88ad76d9a03507e732 to your computer and use it in GitHub Desktop.
Build a pile of Cubes
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