Design Patterns in Java where input n=4 ?

Answer : Pattern is an underlying structure that organizes surfaces…

Design Patterns in Java where input n=4, output like

1
2 3
4 5 6
7 8 9 10 ?
  • Pattern is an underlying structure that organizes surfaces or structures in a consistent, regular manner. Pattern can be described as a repeating unit of shape or form.
  • Given a positive integer n.The problem is to print the pyramid pattern as designed the sample code is given below.

Sample Code

[pastacode lang=”java” manual=”import%20java.io.*%3B%0Aclass%20Wikitechy%20%7B%0A%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20int%20val%20%3D%201%2C%20n%20%3D%204%3B%0A%20%20for%20(int%20i%20%3D%201%3B%20i%20%3C%3D%20n%3B%20i%2B%2B)%20%0A%20%20%7B%0A%20%20%20for%20(int%20j%20%3D%200%3B%20j%20%3C%20i%3B%20j%2B%2B)%20%0A%20%20%20%7B%0A%20%20%20%20System.out.print(val%20%2B%20%22%20%22)%3B%0A%20%20%20%20val%2B%2B%3B%0A%20%20%20%7D%0A%20%20%20System.out.println()%3B%0A%20%20%7D%0A%20%7D%0A%7D” message=”” highlight=”” provider=”manual”/]

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like