You are given an integer `n`. Let `sumOdd` be the sum of the first `n` odd numbers (1 + 3 + 5 + ...) and `sumEven` be the sum of the first `n` even numbers (2 + 4 + 6 + ...). Return the greatest common divisor of `sumOdd` and `sumEven`.
You are given an integer n. Let sumOdd be the sum of the first n odd numbers (1 + 3 + 5 + ...) and sumEven be the sum of the first n even numbers (2 + 4 + 6 + ...). Return the greatest common divisor of sumOdd and sumEven.
Example 1:
Input: {"n":4}
Output: 4
Constraints:
1≤n≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":4}
n = 4. Lay the first 4 odd numbers down as L-shaped layers of a square, and the first 4 even numbers as layers of a rectangle.
each layer is one number; stripes alternate so the layers stay visible