Even or Odd?
InterviewTime limit1sMemory limit512 MB
Given n, decide whether the sum of any n consecutive positive integers is always even, always odd, or depends on the starting point.
- Level
Easy2 of 10
- Topics
- Math, Implementation, Number theory
- Solved
- No attempts yet
Problem
Your friend has secretly picked n consecutive positive integers between 1 and 10^18 and wants you to guess whether their sum is even or odd.
Write 2 if the sum must be even. Write 1 if the sum must be odd. Write 0 if the sum could be even or could be odd.
Input
The single line of input contains a single integer n (1 ≤ n ≤ 10^9).
Output
Output 2 if the sum of any n consecutive integers in the range from 1 to 10^18 must be even, 1 if the sum must be odd, or 0 if the sum could be either even or odd.