Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String cubos(int n) {
- String res = "";
- int auxiliar = 1;
- for (int x = 1; x < n; x++) {
- int suma = 0;
- if (x == 1) {
- res = x + "^3 = " + x + " = 1";
- }
- res += "\n";
- res += x+1 + "^3 = ";
- for (int h = 1; h <= x + 1; h++) {
- auxiliar += 2;
- suma += auxiliar;
- res += auxiliar;
- if (h <= x) res += " + ";
- }
- res += " = " + suma;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement