Given two integers n and g, the task is to generate an increasing sequence of n integers such that:
- The gcd of all the elements of the sequence is g.
- And, the sum of all the elements is minimum among all possible sequences.
Input: n = 6, g = 5
Output: 5 10 15 20 25 30
Input: n = 5, g = 3
Output: 3 6 9 12 15
Approach: The sum of the sequence will be minimum when the sequence will consist of the elements:
g, 2 * g, 3 * g, 4 * g, ….., n * g.
Below is the implementation of the above approach:
5 10 15 20 25 30
- Print all non-increasing sequences of sum equal to a given number x
- Sum of array elements that is first continuously increasing then decreasing
- Number of Permutations such that no Three Terms forms Increasing Subsequence
- Print all increasing sequences of length k from first n natural numbers
- Minimum increment operations to make the array in increasing order
- Generate k digit numbers with digits in strictly increasing order
- Sum of the sequence 2, 22, 222, .........
- Recaman's sequence
- Sylvester's sequence
- Aronson's Sequence
- Connell Sequence
- k-th number in the Odd-Even sequence
- Gould's Sequence
- Farey Sequence
- Juggler Sequence