問題一覧 > 通常問題

No.276 Sum of Consecutive Integers (1)

レベル : / AI推定難易度 : 600 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 256 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 415
作問者 : koyumeishi
お気に入りにしたユーザー ProblemId : 744 / 自分の提出
問題文最終更新日: 2026-06-26 00:04:48
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 120 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。