-
Notifications
You must be signed in to change notification settings - Fork 0
/
Number14.java
56 lines (53 loc) · 1.14 KB
/
Number14.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.*;
public class Number14 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n,i,f=0,j;
System.out.println("Enter number of terms");
n=sc.nextInt();
if(n<=10)
{
for(i=1;i<10;i++)
System.out.print(i+" ,");
System.out.println(i);
}
else
{
for(i=1;i<=10;i++)
System.out.print(i+",");
if(n%2==0)
{
for(j=12;i<n-1;i+=2)
{
System.out.print(j+",");
StringBuffer nm=new StringBuffer();
nm.append(String.valueOf(j));
nm.reverse();
j=Integer.parseInt(nm.toString());
System.out.print(j+",");
j+=2;
}
System.out.print(j+",");
StringBuffer nm=new StringBuffer();
nm.append(String.valueOf(j));
nm.reverse();
j=Integer.parseInt(nm.toString());
System.out.println(j);
}
else
{
for(j=12;i<n;i+=2)
{
System.out.print(j+",");
StringBuffer nm=new StringBuffer();
nm.append(String.valueOf(j));
nm.reverse();
j=Integer.parseInt(nm.toString());
System.out.print(j+",");
j+=2;
}
System.out.println(j);
}
}
}
}