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 29 30 31 32 33 34 35 36 37 38 |
/* Java Pyramid 4 Example This Java Pyramid example shows how to generate pyramid or triangle like given below using for loop. 1 12 123 1234 12345 */ public class JavaPyramid4 { public static void main(String[] args) { for(int i=1; i<= 5 ;i++){ for(int j=0; j < i; j++){ System.out.print(j+1); } System.out.println(""); } } } /* Output of the example would be 1 12 123 1234 12345 */ |
how to print this pattern
1 4 9
4 9 16
9 16 25
hi i want to print
1
3*2
4*5*6
10*9*8*7
how to print for n numbers
*
* *
*
how to print this pattern…
how to print this pattern? example input:5
1
22
333
4444
55555
public class pyramid4 {
public static void main (String[] args)
{
for (int i=1; i<=5;i++)
{
for (int j=0; j<i;j++) {=”” system.out.print(i);=”” }=”” system.out.println(“”);=”” }=”” }=”” }=””>