Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. I check, compile and run every program. Contact me at: aviboots(AT)netvision.net.il
Hostgator 1 Penny

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


6,846 questions

9,748 answers

573 users

How to print Floyds triangle in Java

1 Answer

0 votes
package javaapplication1;
 
// Floyd's triangle is a right-angled triangular of natural numbers

public class JavaApplication1 {
  
    public static void main(String[] args) {
         
        int i, j, rows = 7, n = 1;
 
        for (i = 1; i <= rows; i++)
        {
            for (j = 1; j <= i; j++, n++)
                System.out.print(n + " ");
            System.out.println();
        }
    }
}
    
/*
run:
   
1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15 
16 17 18 19 20 21 
22 23 24 25 26 27 28 
    
*/

 




answered May 15, 2017 by avibootz
...