Beautiful Sequence
Easy Accuracy: 0.0% Submissions: 0 Points: 2

A beautiful sequence is an increasing sequence, in which a term Ai divides all Aj, where j>i. Given N find a beautiful sequenec whose last term is N and length of sequenece is maximum possible.

Example 1:

Input: N = 10
Output: 1 5 10
Explanation: 10 is divisible by
1 and 5, 5 is divisible by 1. 

Example 2:

Input: N = 3
Output: 1 3
Explanation: 3 is divisible by 1.


Your Task:
You don't need to read or print anything. Your task is to complete the function FindSequenece() which takes N as input parameter and returns a list of beautiful sequence.


Expected Time Complexity: O(nLog(n))
Expected Space Complexity: O(1)


1 <= N <= 105

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Beautiful Sequence

Output Window