Skip to main content

Floyd Triangle in java

Floyd Triangle in javafloyd-triangle

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
39
40
41
package pattern;
 
 
import java.util.Scanner;
 
public class Floydtriangle
{
 public static void main(String[] args)
 {
 
    Scanner c =new Scanner(System.in);
 
     System.out.println("Enter length");
     int n=c.nextInt();
 
     int cn=0;
 
     for(int i=1;i<n;i++)
      {
       for(int j=1;j<=i;j++)
       {
         cn++;
         System.out.print(cn);
 
       }
 
       System.out.println();
      } 
   }
}
 
 
output:
 
Enter length
5
 
1
23
456
78910