Divisor Sequences

Given a positive integer A,
find and return the length of the longest sequence a[1], …, a[k] of positive integers such that:

The sum of all a[i] is A.
For each valid i, a[i] < a[i+1].
For each valid i, a[i] divides a[i+1].



Input Format

The only argument given is integer A.

Output Format

Return the length of the longest sequence satisfying the above conditions.

Constraints

1 <= A <= 2*10^9

For Example

Input 1:
    A = 15
Output 1:
    4   (1, 2, 4, 8)

Input 2:
    A = 34
Output 2:
    4   (1, 3, 6, 24)
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Divisor Sequences on Interview Code Editor
Sign Up
to access hints and editorial solutions for Divisor Sequences

Discussion


Loading...
Click here to start solving coding interview questions