Print Floyd Triangle in Java Programming
Learn How To Print Floyd Triangle in Java Programming Language. However, you need to make sure you know How A For Loop Works before getting further with the Java Program Code.
What is A Floyd’s Triangle?
Floyd Triangle Concept is developed by a Mathematician named Robert Floyd. A Floyd Triangle comprises of an Array of Natural Integers (Numbers). It includes Consecutive Numbers, starting with 1 till the Limit entered by the User.
Also Read: Java Code To Count Occurrence of Character in String
Code To Print Floyd Triangle in Java using For Loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import java.iolang:default decode:true.*; import java.util.*; class Floyd { public static void main(String args[]) { int count, a, num = 1; System.out.println("Enter The Limit:\t"); Scanner sc = new Scanner(System.in); int limit = sc.nextInt(); for(count = 1; count <= limit; count++) { for(a = 1; a <= count; a++) { System.out.println(num + "\t"); num++; } System.out.println("\n"); } System.out.println("\n"); } } |
Output

In case you get any Compilation Errors with this Java Program To Display Floyd’s Triangle or you have any doubt about it, mention it in the Comment Section.