fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int n = 8;
  13.  
  14. String del;
  15. String del2 = "";
  16.  
  17. for (int i = 1; i <= n; i++) {
  18. System.out.print(del2 + "(");
  19. del = "";
  20. for (int j = 1; j <= i; j++) {
  21. System.out.print(del + j);
  22. del = " + ";
  23. }
  24. System.out.print(")");
  25. del2 = " + ";
  26.  
  27. }
  28. }
  29. }
Success #stdin #stdout 0.03s 4386816KB
stdin
Standard input is empty
stdout
(1) + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3 + 4) + (1 + 2 + 3 + 4 + 5) + (1 + 2 + 3 + 4 + 5 + 6) + (1 + 2 + 3 + 4 + 5 + 6 + 7) + (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8)