No.276 Sum of Consecutive Integers (1)
タグ : / 解いたユーザー数 415
作問者 :
koyumeishi
Problem Statement
In junior high school mathematics, one proves that the proposition "the sum of $3$ consecutive positive integers is divisible by $3$" is true.
Generalizing this a little, consider the following proposition.
The sum of $N$ consecutive positive integers is divisible by $X$
Given a positive integer $N$, find the largest positive integer $X$ for which this is true.Input
$N$
$N$ ($1\leq N \leq10^{9}$) is given on a single line.
Output
$X$
Output on a single line the largest positive integer $X$ that makes the proposition true.
Sample
Sample 1
Input
3
Output
3
Many of you may have learned in junior high school mathematics that the sum of 3 consecutive positive integers is a multiple of 3.
For example, $1+2+3 = 6$ is a multiple of 3, and $2+3+4 = 9$ is also a multiple of 3.
Sample 2
Input
2
Output
1
Considering $1+2 = 3$, $2+3 = 5$, $100 + 101 = 201$, and so on, the largest $X$ is 1.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。