Pyramid 15



Write a program to generate this Pattern.






Program to generate above pattern >
import java.util.Scanner;
public class Pyramid15 {
   public static void main(String[] args) {
         
          Scanner scanner = new Scanner(System.in);
          System.out.print("Enter n : ");  
          int n = scanner.nextInt();
          System.out.println("");
          for (int i = 1; i <= n; i++) {
                 for (int j = 1, k=i ; j <= i; j++) {
                       System.out.print(k * j+" ");
                 }
                 System.out.println("");
          }
   }
}
/*OUTPUT
Enter n : 5
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
*/


Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.

RELATED LINKS>







eEdit
Must read for you :