# Decrement OR Increment Codechef Solution Hello Programmers In this post, you will know how to solve the Decrement OR Increment Codechef Solution.

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.

### Problem

Write a program to obtain a number N and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1.

### Input Format:

• First line will contain a number N.

### Output Format:

Output a single line, the new value of the number.

• 0 ≤ N ≤ 1000

```5
```

```4
```

### Explanation:

Since 5 is not divisible by 4 hence, its value is decreased by 1.

### Decrement OR Increment CodeChef Solutions in Python

```a = int(input())
if (a % 4 == 0):
a = a + 1
print(int(a))
else:
a = a - 1
print(int(a))```

### Decrement OR Increment CodeChef Solutions in CPP

```#include <stdio.h>
int main(void) {
int N;
scanf("%d",&N);
if(N%4==0)
N=N+1;
else
N=N-1;
printf("%d",N);
return 0;
}```

### Decrement OR Increment CodeChef Solutions in JAVA

```import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
System.out.println(solve(N));
sc.close();
}
static int solve(int N) {
return (N % 4 == 0) ? (N + 1) : (N - 1);
}
}```

Disclaimer: The above Problem (Number Mirror) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.