public class Pattern4
{
public static void main(String[] args)
{
int n = 5;
for(int i = 0 ; i <= n ; i++)
{
for(int j = 0 ; j < i ; j++)
{
System.out.print(j+1);
}
System.out.println("");
}
}
}
Python
lastNumber = 6
for row in range(1, lastNumber):
for column in range(1, row + 1):
print(column),
print("")
C program
#include <stdio.h>
int main()
{
int i,j,n;
n = 8;
for(i=1;i<6;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
}
C# program
using System;
public class Program
{
public static void Main(string[] args)
{
for (int row = 1; row <= 5; ++row)
{
for (int col = 1; col <= row; ++col)
{
Console.Write(col);
}
Console.WriteLine();
}
}
}
JAVA
Python
C program
C# program
PHP program
need an explanation for this answer? contact us directly to get an explanation for this answer