Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,094 questions

40,775 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

Related questions

1 answer 105 views
105 views asked May 15, 2017 by avibootz
1 answer 878 views
878 views asked May 15, 2017 by avibootz
1 answer 2,145 views
1 answer 475 views
475 views asked May 15, 2017 by avibootz
1 answer 158 views
158 views asked May 15, 2017 by avibootz
...