Decrement OR Increment Problem Code: DECINC (CodeChef)

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:

  • First line will contain a number N.

Output:

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

Constraints

  • 0N1000

Sample Input:

5

Sample Output:

4

EXPLANATION:

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

Solution:

N=int(input())

if(N%4==0):

    print(N+1)

else:

    print(N-1)

Comments

Popular posts from this blog

Chef and Remissness Problem Code: REMISS (CodeChef)

Sort in specific order (GFG)

Reverse words in a given string (GFG)