Number Triangle Pattern Program In Java Language
class NumberTriangle{
public static void main(String args[])
{
int n = 5;
for(int i=1; i<=n; i++){
//Spaces
for(int j=i; j<=n-1; j++){
System.out.print(" ");
}
//Numbers
for(int j=1; j<=i; j++){
System.out.print(i + " ");
}
System.out.println();
}
}
}
OUTPUT:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Comments
Post a Comment