In: Computer Science
Print the following two patterns using nested loops. Using java.
Pattern 1
13579
13579
13579
13579
Pattern 2
#####1
### #12
###123
##1234
#12345
import java.util.*;
import java.lang.*;
import java.io.*;
class Patterns
{
   public static void main (String[] args)
   {
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
  
   //Pattern 1
   for(int i = 1; i <= n; i++) // n is the number of
rows
   {
   for(int j = 1; j <= 5; j++)
   {
   System.out.print(2 * j - 1); // printing the row
   }
   System.out.println();    //change line
   }
   System.out.println();
   System.out.println();
  
   //Pattern 2
   int p = n;
   for(int i = 1; i <= n; i++) // n is the number of
rows
   {
   for(int j = 1; j <= p; j++) // print # decreasing
in number
   {
   System.out.print('#');
   }
   p--;
  
   for(int j = 1; j <= i; j++) // every time the
number of numbers in row increases
   {
   System.out.print(j);
   }
   System.out.println(); //change line
   }
   }
}