Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public static String cubos(int n) {
  2. String res = "";
  3. int auxiliar = 1;
  4. for (int x = 1; x < n; x++) {
  5. int suma = 0;
  6. if (x == 1) {
  7. res = x + "^3 = " + x + " = 1";
  8. }
  9. res += "\n";
  10. res += x+1 + "^3 = ";
  11. for (int h = 1; h <= x + 1; h++) {
  12. auxiliar += 2;
  13. suma += auxiliar;
  14. res += auxiliar;
  15. if (h <= x) res += " + ";
  16. }
  17. res += " = " + suma;
  18. }
  19. return res;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement