Created
June 6, 2018 02:48
-
-
Save thmain/dcefeb08adc0ac017efdb54e7a009065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FloydTriangle { | |
public static void printTriangle(int rows){ | |
if(rows<=0) | |
return; | |
int count=1; | |
int number = 1; | |
while(count<=rows){ | |
for (int i = 0; i <count ; i++) { | |
System.out.print(number + " "); | |
number++; | |
} | |
count++; | |
System.out.println(); | |
} | |
} | |
public static void main(String[] args) { | |
int rows = 7; | |
printTriangle(rows); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment