Skip to content

Commit 37e6999

Browse files
Arithmetic Number
1 parent 6ca9a80 commit 37e6999

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution{
2+
static int inSequence(int A, int B, int C){
3+
// code here
4+
if (C == 0) {
5+
if (A == B) {
6+
return 1;
7+
}
8+
else {
9+
return 0;
10+
}
11+
}
12+
else if (A==B) {
13+
return 1;
14+
}
15+
else if (C>0 && (B-A)%C==0 && B>A) {
16+
return 1;
17+
}
18+
else if(C<0 && (B-A)%C ==0 && A>B) {
19+
return 1;
20+
}
21+
else {
22+
return 0;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)