fork 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. Scanner sc = new Scanner (System.in);
  13.  
  14.  
  15. int n = Integer.parseInt(sc.nextLine());
  16. int a = 0;
  17. int b = 0;
  18. for (int i = 1; i <= n; i++) {
  19. if ( i > a) {
  20. b++;
  21. a = a + b;
  22.  
  23. }
  24. System.out.print( b + " ");
  25. }
  26.  
  27. }
  28. }
Success #stdin #stdout 0.05s 711680KB
stdin
7
stdout
1 2 2 3 3 3 4