yovkovbpfps

Nested LOOPS NUMBER OF PYRAMID

Apr 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1.  
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Piramide_Numbers {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. Scanner scanner = new Scanner( System.in );
  10.  
  11. int n = Integer.parseInt( scanner.nextLine());
  12. int count = 0;
  13.  
  14. for ( int i = 1; i <= n; i++) {
  15.  
  16. for ( int k = 1; k <= i; k++ ) {
  17. count++;
  18. System.out.printf("%d ", count);
  19. if (count == n ) return;
  20. }
  21. System.out.println();
  22. }
  23.  
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment