Advertisement
CoineTre

01.Number Pyramid-Floyd Triangle

Nov 28th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NumberPyramidFloydTriangle {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int number = Integer.parseInt(scanner.nextLine());
  7.         int counter = 1;
  8.         boolean found = false;
  9.         for (int i = 1; i <=number; i++) {
  10.             for (int j = 1; j<=i; j++) {
  11.                 System.out.printf("%d ",counter++);
  12.                 if (counter>number){
  13.                     found=true;
  14.                     break;
  15.                 }
  16.             }
  17.             if (found){
  18.                 break;
  19.             }
  20.             System.out.println();
  21.         }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement