-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtecy_num.java
More file actions
43 lines (35 loc) · 848 Bytes
/
btecy_num.java
File metadata and controls
43 lines (35 loc) · 848 Bytes
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
public class btecy_num {
public static void main(String[] args) {
//int num=123;
int sum=0;
for(int i=8;i<=19;i++)
{
if(isbtecy(i))
{
//System.out.println("True");
sum=sum+i;
System.out.println("sum of="+sum);
}
/*else{
System.out.println("False");
}*/
}
}
public static boolean isbtecy(int num)
{
while(num>10)
{
int last=num%10;
int pre=(num/10)%10;
int total=last-pre;
if(check(total)!=1)
return false;
num=num/10;
}
return true;
}
public static int check(int n)
{
return n==1||n==-1?1:0;
}
}