We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0d8b32d commit bd752b3Copy full SHA for bd752b3
Pattern-2/Odd_Square.java
@@ -0,0 +1,35 @@
1
+/*
2
+Write a program to print the pattern for the given N number of rows.
3
+For N = 4
4
+1357
5
+3571
6
+5713
7
+7135
8
+*/
9
+
10
+import java.util.*;
11
12
+public class Odd_Square {
13
14
+ public static void main(String[] args) {
15
16
+ // Write your code here
17
18
+ Scanner sc = new Scanner(System.in);
19
+ int n = sc.nextInt();
20
21
+ for (int i = 1; i <= n; i++)
22
+ {
23
+ for (int j = i - 1; j < n; j++ )
24
25
+ System.out.print(j * 2 + 1 + "");
26
+ }
27
+ for(int k = 0; k < i - 1; k++)
28
29
+ System.out.print(k * 2 + 1 + "");
30
31
+ System.out.println();
32
33
34
35
+}
0 commit comments