Problem
Write a program to obtain a number and increment its value by 1 if the number is divisible by 4 decrement its value by 1.
Input:
- First line will contain a number .
Output:
Output a single line, the new value of the number.
Constraints
Sample Input:
5
Sample Output:
4
### EXPLANATION:
Since 5 is not divisible by 4 hence, its value is decreased by 1.
Program :
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n%4==0)
n+=1;
else
n-=1;
System.out.println(n);
}
}
0 Comments