34
1
You should write a program or function that given a list of positive integers multiplies each element with the smallest positive integer possible to create a strictly increasing list.
For example if the input is
5 4 12 1 3
the multiplications will be
5*1=5 4*2=8 12*1=12 1*13=13 3*5=15
and the output will be the increasing list
5 8 12 13 15
Input
- A list of positive integers containing at least 1 element
Output
- A list of positive integers
Examples
9 => 9
1 2 => 1 2
2 1 => 2 3
7 3 => 7 9
1 1 1 1 => 1 2 3 4
5 4 12 1 3 => 5 8 12 13 15
3 3 3 8 16 => 3 6 9 16 32
6 5 4 3 2 1 => 6 10 12 15 16 17
9 4 6 6 5 78 12 88 => 9 12 18 24 25 78 84 88
8 9 41 5 12 3 5 6 => 8 9 41 45 48 51 55 60
15 8 12 47 22 15 4 66 72 15 3 4 => 15 16 24 47 66 75 76 132 144 150 153 156
This is code golf so the shortest program or function wins.
Fun fact: the last element of the output for the input N, N-1, ... ,1
seems to be the (N+1)th
element of the sequence A007952. If you find a proof, you are welcomed to include it in your golf answer or post it as a comment.
has anyone made ground on that proof yet? – Connor Clark – 2016-02-10T22:53:33.147