All problems

Find All Divisors of a Number

easyPythonMath

A workshop cuts a plank of a whole number of centimetres into equal pieces with nothing left over, and the foreman wants every possible piece length listed before choosing one. A length works exactly when it goes into the plank a whole number of times with no offcut — those lengths are the plank's divisors. Cutting into 1 cm pieces always works, and so does leaving the plank whole.

Task: Print every whole number that divides n exactly, smallest first.

Input

A single line holding one integer n, with 1 ≤ n ≤ 100,000.

Output

One line holding the divisors in increasing order, separated by single spaces. Both 1 and n itself are divisors and both belong on the line — when n is 1 they are the same number, and the line holds a single 1.

Example:

Input:
12

Output:
1 2 3 4 6 12

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…