floyd's triangle pattern in java.
■》 code link -> click 👇👇👇👇
■》 Input->
import java.util.*;public class floydtriangle {
public static void main(String[] args) {
int number=1;
Scanner sc=new Scanner(System.in);
System.out.println("enter no. of row=");
int n=sc.nextInt();
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
System.out.print(number+" ");
number++;
}
System.out.println();
}
}
}
■》Output->
enter no. of row=5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
-------------------------------‐--------------------------
Comments
Post a Comment