[Question]
  [
Given two positive integers **p** and **q**, your task is to return the array **A** created by applying the following algorithm:
1. Start with **A = [p, q]** and **d = 2**
2. For each pair **(x, y)** of contiguous numbers in **A** whose sum is divisible by **d**, insert **(x + y) / d** between **x** and **y**.
3. If at least one matching pair was found, increment **d** and go on with step #2. Otherwise, stop and return **A**.
## Example
Below is the detail of the process for **p = 1** and **q = 21**.
```
  1  21             | Iteration #1: we start with d = 2 and A = [1, 21]
   \/               |               1 + 21  is divisible by 2 -> we insert 11
 22/2=11            |
                    |
  1  11 21          | Iteration #2: d = 3, A = [1, 11, 21]
   \/               |               1 + 11  is divisible by 3 -> we insert 4
 12/3=4             |
                    |
  1 4 11  21        | Iteration #3: d = 4, A = [1, 4, 11, 21]
        \/          |               11 + 21 is divisible by 4 -> we insert 8
      32/4=8        |
                    |
  1    4    11 8 21 | Iteration #4: d = 5, A = [1, 4, 11, 8, 21]
    \/   \/         |               1 + 4   is divisible by 5 -> we insert 1
  5/5=1 15/5=3      |               4 + 11  is divisible by 5 -> we insert 3
                    |
  1 1 4 3 11 8 21   | Iteration #5: d = 6, A = [1, 1, 4, 3, 11, 8, 21]
                    |               no sum of two contiguous numbers is divisible by 6
                    |               -> we stop here
```
Hence the expected output: **[1, 1, 4, 3, 11, 8, 21]**
## Clarifications and rules
* Input and output can be handled in any reasonable format. The integers **p** and **q** are guaranteed to be greater than 0. If that helps, you may assume **q ≥ p**.
* The 2nd step of the algorithm should ***not*** be recursively applied to elements that have just been inserted at the same iteration. For instance, **A = [1, 1]** and **d = 2** should lead to **[1, 1, 1]** (not an infinite list of 1's).
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins!
## Test cases
```
  p |   q | Output
----+-----+-------------------------------------------------------------------------------
  1 |   1 | [1,1,1]
  1 |   2 | [1,2]
  1 |   3 | [1,1,2,3]
  2 |   6 | [2,1,2,1,4,1,2,6]
  3 |  13 | [3,1,8,1,3,1,7,1,2,1,5,1,3,2,13]
  9 |   9 | [9,6,9,6,9]
 60 |  68 | [60,13,1,4,31,2,3,5,2,19,64,7,13,1,2,5,2,27,44,3,4,8,2,1,12,1,5,3,28,2,4,16,1,
    |     |  2,12,1,2,1,10,1,6,68]
144 | 336 | [144,68,3,4,8,1,12,1,4,2,28,13,128,44,17,92,240,58,108,5,17,1,2,5,3,28,3,1,11,
    |     |  60,3,6,2,42,2,4,26,192,54,132,7,1,15,1,3,1,18,1,4,2,30,3,1,12,1,9,78,46,336]
```
If you'd like to test your code on a slightly bigger test case, [**here**](https://pastebin.com/6giBKNhC) is the expected output for:
* **p = 12096** (26\*33\*7)
* **q = 24192** (27\*33\*7)
  
[Answer]
# Mathematica, ~~72~~ ~~64~~ ~~59~~ 58 bytes
```
(d=2;#//.x_:>Riffle[x,(x+{##2,}&@@x)/d++]~Cases~_Integer)&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7XyPF1shaWV9fryLeyi4oMy0tJzW6QkejQrtaWdlIp1bNwaFCUz9FWzu2zjmxOLW4Lt4zryQ1PbVIU@1/QFFmXomCvoNCGoio5lIAgmpDHQXDWh042wiJbQxjG@komMHYxkD1cAlLHQVLGNvMAKjKAq7dxARogLFZLVftfwA "Wolfram Language (Mathematica) – Try It Online")
### How it works
We take the input as a list `{p,q}`. The iteration step is reformulated as:
1. Insert `(a+b)/d` between *every* two elements `a` and `b`: `(x+{##2,}&@@x)` computes the sequence of `a+b`'s, with an `a+Null` at the end. We divide by `d`, and `Riffle` inserts each `(a+b)/d` between `a` and `b`. Increment `d`.
2. Pick out the `Integer` elements of the resulting list. (This gets rid of the `Null` introduced by `{##2,}`, too.)
This is repeated until the result doesn't change (which can only happen because we removed all the new elements, because none of them were integers).
*-8 bytes thanks to @MartinEnder from using `//.` instead of `FixedPoint` (and from taking input as a list).*
*-6 more because `ListConvolve` actually isn't that great*
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~28~~ ~~19~~ 18 bytes
```
[Ðü+NÌ/‚ζ˜ʒ.ï}DŠQ#
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/@vCEw3u0/Q736D9qmHVu2@k5pybpHV5f63J0QaAyUNbQyMDSTMfIxNDSKBYA "05AB1E – Try It Online")
---
~~eh, can definitely be improved hardcore. still working to refactor.~~ 
~~Probably as good as I'm getting it.~~
***-1 thanks to, who else but, Emigna! For pointing out swap worked better than the registers.***
---
```
[                   // Infinite loop.
 Ð                  // Triplicate [p, ..., q]
  U                 // Pop 1 of 3 copies into register X.
   ü+               // Pairwise addition.
     NÌ/            // Divide by current iteration + 2 (which is d).
        ‚           // Group original [p, ..., q] with pairwise additives.
         ζ˜         // Transpose together and flatten.
           ʒ.ï}     // Filter out non-integer entities (includes the space added by zip).
               DXQ  // Dupe result, see if equal to original.
                  # // If new array is original array, nothing happened, quit & return.
```
---
Debug dump for `[p,q] = [1,3]`:
```
Full program: [ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> [  ||  stack: []
ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
Full program: ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> Ð  ||  stack: []
current >> U  ||  stack: [[1, 3], [1, 3], [1, 3]]
current >> ü  ||  stack: [[1, 3], [1, 3]]
Full program: +
current >> +  ||  stack: [1, 3]
stack > [4]
current >> N  ||  stack: [[1, 3], [4]]
current >> Ì  ||  stack: [[1, 3], [4], 0]
current >> /  ||  stack: [[1, 3], [4], 2]
current >> ‚  ||  stack: [[1, 3], [2.0]]
current >> ζ  ||  stack: [[[1, 3], [2.0]]]
current >> ˜  ||  stack: [[[1, 2.0], [3, ' ']]]
current >> ʒ  ||  stack: [[1, 2.0, 3, ' ']]
Filter: .ï
Full program: .ï
current >> .  ||  stack: [1]
stack > [1]
Full program: .ï
current >> .  ||  stack: [2.0]
stack > [1]
Full program: .ï
current >> .  ||  stack: [3]
stack > [1]
Full program: .ï
current >> .  ||  stack: [' ']
invalid literal for int() with base 10: ' '
stack > []
current >> D  ||  stack: [[1, 2.0, 3]]
current >> X  ||  stack: [[1, 2.0, 3], [1, 2.0, 3]]
current >> Q  ||  stack: [[1, 2.0, 3], [1, 2.0, 3], [1, 3]]
current >> #  ||  stack: [[1, 2.0, 3], 0]
stack > [[1, 2.0, 3]]
Full program: ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> Ð  ||  stack: [[1, 2.0, 3]]
current >> U  ||  stack: [[1, 2.0, 3], [1, 2.0, 3], [1, 2.0, 3]]
current >> ü  ||  stack: [[1, 2.0, 3], [1, 2.0, 3]]
Full program: +
current >> +  ||  stack: [1, 2.0]
stack > [3.0]
Full program: +
current >> +  ||  stack: [3.0, 2.0, 3]
stack > [3.0, 5.0]
current >> N  ||  stack: [[1, 2.0, 3], [3.0, 5.0]]
current >> Ì  ||  stack: [[1, 2.0, 3], [3.0, 5.0], 1]
current >> /  ||  stack: [[1, 2.0, 3], [3.0, 5.0], 3]
current >> ‚  ||  stack: [[1, 2.0, 3], [1.0, 1.6666666666666667]]
current >> ζ  ||  stack: [[[1, 2.0, 3], [1.0, 1.6666666666666667]]]
current >> ˜  ||  stack: [[[1, 1.0], [2.0, 1.6666666666666667], [3, ' ']]]
current >> ʒ  ||  stack: [[1, 1.0, 2.0, 1.6666666666666667, 3, ' ']]
Filter: .ï
Full program: .ï
current >> .  ||  stack: [1]
stack > [1]
Full program: .ï
current >> .  ||  stack: [1.0]
stack > [1]
Full program: .ï
current >> .  ||  stack: [2.0]
stack > [1]
Full program: .ï
current >> .  ||  stack: [1.6666666666666667]
stack > [0]
Full program: .ï
current >> .  ||  stack: [3]
stack > [1]
Full program: .ï
current >> .  ||  stack: [' ']
invalid literal for int() with base 10: ' '
stack > []
current >> D  ||  stack: [[1, 1.0, 2.0, 3]]
current >> X  ||  stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> Q  ||  stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3], [1, 2.0, 3]]
current >> #  ||  stack: [[1, 1.0, 2.0, 3], 0]
stack > [[1, 1.0, 2.0, 3]]
Full program: ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> Ð  ||  stack: [[1, 1.0, 2.0, 3]]
current >> U  ||  stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> ü  ||  stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
Full program: +
current >> +  ||  stack: [1, 1.0]
stack > [2.0]
Full program: +
current >> +  ||  stack: [2.0, 1.0, 2.0]
stack > [2.0, 3.0]
Full program: +
current >> +  ||  stack: [2.0, 3.0, 2.0, 3]
stack > [2.0, 3.0, 5.0]
current >> N  ||  stack: [[1, 1.0, 2.0, 3], [2.0, 3.0, 5.0]]
current >> Ì  ||  stack: [[1, 1.0, 2.0, 3], [2.0, 3.0, 5.0], 2]
current >> /  ||  stack: [[1, 1.0, 2.0, 3], [2.0, 3.0, 5.0], 4]
current >> ‚  ||  stack: [[1, 1.0, 2.0, 3], [0.5, 0.75, 1.25]]
current >> ζ  ||  stack: [[[1, 1.0, 2.0, 3], [0.5, 0.75, 1.25]]]
current >> ˜  ||  stack: [[[1, 0.5], [1.0, 0.75], [2.0, 1.25], [3, ' ']]]
current >> ʒ  ||  stack: [[1, 0.5, 1.0, 0.75, 2.0, 1.25, 3, ' ']]
Filter: .ï
Full program: .ï
current >> .  ||  stack: [1]
stack > [1]
Full program: .ï
current >> .  ||  stack: [0.5]
stack > [0]
Full program: .ï
current >> .  ||  stack: [1.0]
stack > [1]
Full program: .ï
current >> .  ||  stack: [0.75]
stack > [0]
Full program: .ï
current >> .  ||  stack: [2.0]
stack > [1]
Full program: .ï
current >> .  ||  stack: [1.25]
stack > [0]
Full program: .ï
current >> .  ||  stack: [3]
stack > [1]
Full program: .ï
current >> .  ||  stack: [' ']
invalid literal for int() with base 10: ' '
stack > []
current >> D  ||  stack: [[1, 1.0, 2.0, 3]]
current >> X  ||  stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> Q  ||  stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> #  ||  stack: [[1, 1.0, 2.0, 3], 1]
[1, 1.0, 2.0, 3]
stack > [[1, 1.0, 2.0, 3]]
```
[Try it online with debug!](https://tio.run/##MzBNTDJM/f8/@vCE0MN7tP0O9@g/aph1btvpOacm6R1eX@sSEagMlDU0MdExNjaL/a@bAgA "05AB1E – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 80 bytes
```
->a,d=2{*b=a[0];a.each_cons 2{|x,y|z=x+y;b+=z%d>0?[y]:[z/d,y]};b==a ?a:f[b,d+1]}
```
[Try it online!](https://tio.run/##bc7dCoIwFAfw@57iYHSTq9wmwynTBxkjNk26qsgE58ezmxqKQjcHdn7/c87epbF9LvpTrFEmSHM0QktPRfp80@n9mj4fBZCmrZBta1G5NjKuqA9Z7CXSqlDWlwxZ1UVGCA2JDnNpUOZi1fWv8lOAA4ChhV/dN7mUGAFWqnN2WycrJ3@crpxunEzOZicI2MbHScDLPB3ubxfwaQGfAxwBXzvzRmfB7MwbLgSrBPb9wShdvjA00PgeM/0X "Ruby – Try It Online")
Recursive function `f` taking input as the array `[p, q]`.
[Answer]
## Haskell, ~~85~~ 81 bytes
```
(a:b:c)#d=a:[div(a+b)d|mod(a+b)d<1]++(b:c)#d
l#d=l
l%d|l==l#d=l|e<-d+1=l#d%e
(%2)
```
[Try it online!](https://tio.run/##XYpLCsMgFAD3nuJBKyhaqFlIkXiS4ML0GSp9@dCGrLy7/WTV7maGucXnPRHVKqLr3VUe0EfXYd5EVL3EMs64U2uCUmJfGL03YsSxkPdfKak9oTIf4YkNXvBG1jHmCTzgDAxgeeRphSMM0Bltwm9ptP0r9qztJdQX "Haskell – Try It Online")
The input is taken as a list, e.g. `[1,2]`.
Edit: -4 bytes thanks to @Laikoni.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~112~~ ~~110~~ ~~108~~ ~~105~~ 103 bytes
-2 bytes thanks to Jonathan Frech  
-5 bytes thanks to Erik the Outgolfer  
```
y=input()
x=d=1
while x!=y:
 d+=1;x=y;y=x[:1]
 for a,b in zip(x,x[1:]):c=a+b;y+=[c/d,b][c%d>0:]
print x
```
[Try it online!](https://tio.run/##BcFBCsMgEADA@75ieygkKLQ2N2X7EfEQtSVCMRIM3e3n7UyTvu31MYZQqe3s0wxMmQx8t/J5IV9ILGBWZByTOCH21gTA937gqiOWir/SJtbsjQ2zTbSq6ESRT7esY/Dpmp93G6AdpXbkMfyi0SzhDw "Python 2 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 98 bytes
```
f=lambda A,B=0,d=2:A*(A==B)or f(sum([[(l+r)/d,r][(l+r)%d>0:]for l,r in zip(A,A[1:])],A[:1]),A,d+1)
```
Invoke as `f([p,q])`. [Try it online!](https://tio.run/##JYxBCsMgEEWv4qYwNgONLoUpTK4hLlJEKhgj03TRXt4IWf3H4/Hb73jv1faeqKzbK66KcaEZI1nHd2CiRe@iEny@G3gPZRL9iCjhwlt8zi6kURQUlav65waM7I0LOox1JmhkjJPRvUmux7jyBu3Q/QQ "Python 2 – Try It Online")
Jonathan Allan saved 12 bytes. Thanks~!
## Explanation
`f` is a recursive function: `f(A, B, d)` evalutes to `f(next_A, A, d+1)`, unless `A == B`, in which case it returns `A`. (This is handled by `A*(A==B)or …`: if A ≠ B, `A*(A==B)` is the empty list, which is false-y, so the `…` part is evaluated; if A = B then `A*(A==B)` is `A`, which is non-empty and thus truthy, and it gets returned.)
`next_A` is computed as:
```
sum([[(l+r)/d,r][(l+r)%d>0:]for l,r in zip(A,A[1:])],A[:1])
```
This is best explained by example. When e.g. `d = 5` and `A = [1, 4, 11, 8, 21]`:
```
  sum([[(l+r)/d,r][(l+r)%d>0:]for l,r in zip(A,A[1:])],A[:1])
= sum([[(1+4)/d, 4], [(4+11)/d, 11], [8], [21]], [1])
= [1] + [1, 4] + [3, 11] + [8] + [21]
= [1, 1, 4, 3, 11, 8, 21]
```
[Answer]
# [Python 2](https://docs.python.org/2/), 111 bytes
```
A=input()
m=d=1
while m:
 m=o=0;d+=1
 while A[o+1:]:
	o+=1;s=A[o-1]+A[o]
	if s%d<1:A[o:o]=s/d,;m=1;o+=1
print A
```
[Try it online!](https://tio.run/##JcpBCgIxDIXh9eQU2QhKRzTOrjWLnmPorsoUbFNsRTx9jbh6vI@/fvom5TKG51Tqq@8PkDkywXtLjxtmC5hZ@OyiUcS/@lUM2WBhElXXWOFIwegEmNId2y5eyeq1Erid4uyydr8Y6jOVjn6MdZmRlvAF "Python 2 – Try It Online")
-8 thanks to [Rod](https://codegolf.stackexchange.com/users/47120/rod).  
-2 thanks to [Lynn](https://codegolf.stackexchange.com/users/3852/lynn).
[Answer]
# [Husk](https://github.com/barbuz/Husk), 22 bytes
```
→UG`λf£NΣẊṠeo/⁰+:.)⁰tN
```
Takes a 2-element list, returns list of integers and floats.
[Try it online!](https://tio.run/##yygtzv7//1HbpFD3hHO70w4t9ju3@OGuroc7F6Tm6z9q3KBtpacJpEr8/v//H22sY2gcCwA "Husk – Try It Online")
## Explanation
```
→UG`λf£NΣẊṠeo/⁰+:.)⁰tN  Input is a list L.
  G                 tN  Cumulative reduce over the list [2,3,4..
                   ⁰    with initial value L
   `λ             )     using flipped version of this function:
     f£NΣẊṠeo/⁰+:.       Arguments are a list, say K=[1,3,3], and a number, say d=4.
                :.       Prepend 0.5: [0.5,1,2,3]
         Ẋ               For each adjacent pair,
               +         take their sum,
            o/⁰          divide by d,
          Ṡe             and pair it with the right number in the pair: [[0.375,1],[1.0,3],[1.5,3]]
        Σ                Concatenate: [0.375,1,1.0,3,1.5,3]
     f£N                 Remove non-integers: [1,1.0,3,3]
                        Now we have an infinite list of L threaded through 2,3,4.. using the expansion operation.
 U                      Take longest prefix of unique elements,
→                       then last element of that.
```
[Answer]
# [Perl 5](https://www.perl.org/), 92 + 1 (`-a`) = 93 bytes
```
do{$c=0;@n=shift@F;$.++;push@n,($t=$_+$n[-1])%$.?$_:($c=$t/$.,$_)for@F;@F=@n}while$c;say"@F"
```
[Try it online!](https://tio.run/##DcvRCsIgFADQX4lxgw2nuYc9LJHuk299QYSMtaEwVKYREf16t533k@Zt7Yke8QOTlgqDzs4vBY0CwZhKz@wwtDUUDZZBuPHu3hxBXMCe631AOYFowTZL3PaDRmP4vpxfZ5hUHt8VmopoOAy/mIqPIRO/9kJ2kvj4Bw "Perl 5 – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina), 111 bytes
```
\d+
$*1;
^
11@
{+`(1+); (1+);
$1; $1$2 $2;
(?<=(?=(1+)).*) (\1)+ 
 a$#2$*1; 
 1+ 
 
.*a
1$&
)`a
1+@
1+
$.&
;
```
[Try it online!](https://tio.run/##HYwxCsMwEAT7fcVBDqPTgWDVXoz9EBMsiAs3KUK6PF6J3Aw7LMz7@Jyv1vv2dGhm4AFyxdf3RLeQi1CGKLWK1kBa7nNa5vFYySZpo7lAmt7qSPwnh6PkBuoE2xtAXwegZUKgd0rlDw "Retina – Try It Online")
Takes the input as space separated numbers. Quite naively follows the given algorithm, with the only notable technique being to use a marker symbol, `a`, to note when any of the numbers had been kept. This is used to work with Retina's somewhat limited looping capabilities, which only allows you to loop until a set of stages makes no overall change to the input to those stages.
### Explanation:
This will use the same example as in the question.
```
\d+
$*1;
```
We change the input array of numbers into a semicolon separated unary array, so we'd have: 
```
1; 111111111111111111111;
^
11@
```
Put `d` into our code at the beginning, giving us:
```
11@1; 111111111111111111111;
{+`(1+); (1+);
$1; $1$2 $2;
```
This is slightly more complicated. `{` starts a group of stages that will be executed until they reach a fixed point. Then, `+` indicates that this stage itself should be executed until a fixed point. This stage adds each pair of adjacent numbers but inserts them without the additional semicolon. Now we'd have:
```
11@1; 1111111111111111111111 111111111111111111111;
(?<=(?=(1+)).*) (\1)+ 
 a$#2$*1;
```
The other tricky stage, this one accumulates our divisor in the first capture group, and replaces any number in our list without a trailing semicolon with that number divided by `d`. We also add a leading `a` to these numbers, to indicate that something was kept, along with the `;` to indicate it should be permanently part of the array. Now we'd have:
```
11@1; a11111111111; 111111111111111111111;
```
```
 1+ 
```
This deletes numbers that were not divisible by `d` nor in the array before this round. This makes no changes in our example.
```
.*a
1&$
```
This greedily matches from the beginning of the string to the last letter `a` in the input. This means there can be at most one match. If we made any changes, we add one to `d`, otherwise leaving it the same so we can exit the loop.
```
111@1; a11111111111; 111111111111111111111;
```
```
)`a
```
The `)` closes the loop started by `{` (don't question it!) and otherwise this stage just removes the markers we put down earlier. Since this is the end of the loop, we would repeat the above stages many times, however I'm just going to continue as though I had forgotten the loop, since it makes the example more continuous.
```
111@1; 11111111111; 111111111111111111111;
```
```
1+@
```
This stage removes from our output:
```
1; 11111111111; 111111111111111111111;
1+
$.&
```
This stage replaces the unary numbers with decimal numbers:
```
1; 11; 21;
```
```
;
```
The final stage gets rid of the semicolons:
```
1 11 21
```
Obviously, skipping out on the loop makes us have an incorrect result here, but hopefully that isn't too confusing.
[Answer]
# JavaScript (ES6), ~~89~~ ~~87~~ 82 bytes
*Thanks [@Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld) for -2 bytes and for helping save 5 more bytes.*
```
f=(a,d=2,r)=>a.map(v=>b.push(v,...(v+=a[++i])%d<1?[r=v/d]:[]),b=i=[])|r?f(b,d+1):a
```
Takes input as an array: `f([p,q])`.
## Test Cases
```
f=(a,d=2,r)=>a.map(v=>b.push(v,...(v+=a[++i])%d<1?[r=v/d]:[]),b=i=[])|r?f(b,d+1):a
;[[1,1],[1,2],[1,3],[2,6],[3,13],[9,9],[60,68],[144,336],[12096,24192]]
.forEach(test=>O.innerText+=JSON.stringify(test)+" -> "+JSON.stringify(f(test))+"\n")
```
```
<pre id=O></pre>
```
[Answer]
# [Röda](https://github.com/fergusq/roda), 90 bytes
```
f a,d=2{A=[a()|slide 2|[_,(_1+_)/d]if[(_1+_2)%d=0]else[_1]]+a[-1]f A,d=d+1 if[a!=A]else A}
```
[Try it online!](https://tio.run/##Rc1BCoMwEIXhtZ5iuigYnFITRWohC88RQggmAcFqMdmpZ7diSguz@BY/8@bJ6H13oNFwtrRc6IysfuiNBbYKhZmiuSJ3I3snTjNyNbyQdvBWKCplrsWNSgft8cDkFI5OX3h7BtBu@0v3IyxpEqwPqtPeenhyEGmSCIqMSoz6gUUwrCNKpGVUg01EXWD9@PZVhWVZyzQ57j33Y8iEy0JHJAE3zRA6OOb/2@m2fwA "Röda – Try It Online")
[Answer]
# Java 8, 180 bytes
```
import java.util.*;p->q->{List<Integer>r=new Stack();r.add(p);r.add(q);for(int d=1,f=d,i;f==d++;)for(i=1;i<r.size();i++)if((q=r.get(i)+r.get(i-1))%d<1)r.add(i++,q/(f=d));return r;}
```
**Explanation:**
[Try it here.](https://tio.run/##lZBNT8JAEIbv/Iq5mOzadrFAiGZpjyYmmphwNB6WdosLZXe7nWKQ8NvroqXxZknm8Gbmma93I/YiMlbqTb5t1c4ah7DxOdagKtktB4DxGF6FT5sC8EPC6oAyykyjcTTKSlHX8CKUPo4AahSosj/tRaMzVEazx04snjTKtXThMOhZ1ZimkEECrY3SKkqP59QFSF2i5ScsUWRbQrljIs@JvYiK8sI4ojRCnsRhkeSh4kWS5EHA6U8liblaOFarL@nbVRBQVRBSJY6tJRJFg05EMaU3@SKmv4M9GFZj4gdSv0ti4zQ4fmq5t8CHbVald6EzY29UDjtvEFmiU3r99g6Cns0CWB5qlDtmGmTWl7DUJGPC2vJAYtqJiV/NB9NXwZNr4OkAeHKB5wPgaX/zkNEPtBf/w/O7/pD7IT/OZv2X0@700@jUfgM)
```
import java.util.*;           // Required import for List and Stack
p->q->{                       // Method with two integer parameters and List return-type
  List<Integer>r=new Stack(); //  Result-list
  r.add(p);r.add(q);          //  Add the two input-integers to the List
  for(int d=1,                //  Divisible integer (starting at 1)
          f=d,                //  Temp integer (starting at `d` / also 1)
          i;                  //  Index-integer
      f==d++;)                //  Loop (1) as long as `f` and `d` are equal
                              //  (and raise `d` by 1 so it starts at 2 inside the loop)
    for(i=1;                  //   Reset index-integer to 1
        i<r.size();i++)       //   Inner loop (2) over the List
      if((q=r.get(i)+r.get(i-1)) 
                              //    If the current + previous items (stored in `q`)
         %d<1)                //    are divisible by `d`:
        r.add(i++,q/(f=d));   //     Insert `q` divided by `d` to the List at index `i`
                              //     (and raise `i` by 1 and set `f` to `d` in the process)
                              //   End of inner loop (2) (implicit / single-line body)
                              //  End of loop (1) (implicit / single-line body)
  return r;                   //  Return the result-List
}                             // End of method
```
[Answer]
**C#, 280 bytes**
```
using System.Linq;class A{static void Main(string[] p){var l=new System.Collections.Generic.List<int>(p.Select(int.Parse));int r,d=2,c;do{c=0;for(int i=1;i<l.Count;++i){if((r=l[i-1]+l[i])%d==0){l.Insert(i++,r/d);++c;}}++d;}while(c>0);l.ForEach(v=>System.Console.Write((v+" ")));}}
```
First attempt at code golf, which is the whole program.
[Test It](https://tio.run/##PY7BSgMxEIZfJRSEhGzjri29pFkQUREUhB48lD2EJLUDMamZdIss@@wxPehpZvi/@fgNLg2aUs4I4ZPsfjC7L/EK4VsarxHJ/YRZZzBkjGDJm4ZAMafK7gdyYtOoE/EquMvf60P03pkMMaB4dsElMFWHeQsh9/Qkdu4a03qJd53QMSbrTlJj1V1jpI2TUa08xHRFCKhOwtZX6zlkyTmwCQ6UJuX3sOwGXsfAbqxSLZu8eAnoUnVz3qRbyypv5DxzbuV8OYJ31PQtk148xfSozZGOqv9vHTB6Jz4SZEfpyBdkwWq1eS6ldOt1Wa02vw)
**Attempt 2, 159 bytes**
Taking away the scaffolding, since the task is to provide a function that can take a pair of numbers (an array works) and returns an array. 
Given that a Func<int[],int[]> *F* can be used to satisfy the requirements, just define *F*:
```
F=v=>{var l=new List<int>(v);int i,r,d=2,c;do{c=0;for(i=1;i<l.Count;++i){if((r=l[i-1]+l[i])%d==0){l.Insert(i++,r/d);++c;}}++d;}while(c>0);return l.ToArray();};
```
[Test Full Program Here](https://tio.run/##XZJPa@MwEMXv/hRDYUHCjvOHvakOlEJKoQsLDewh5KCVJ82ALGUlOdkS/Nm9Y9el3V489vB7mnlPNnFmounbSO4Fnl9jwkZln7/Ke28tmkTexfIBHQYyX4gncn@@tLb4N6ksM1bHCHeJW6e0vfjsmkFMOpGBs6cafmhyIqbAyt0edHiJMgNmYD6H7RHh0LpxMjRtTKCNwRMXOGkK4A/g2uY3hghCOxYH/QqG347e1hMkQbsaAqY2MDFBJQBP2PDRt@TSbl@MzzVsVL@pztX6etYBbOXwAk8U0wCtxVkqrkBFKOpqVRhV@6upFurgg6BqqejWclKtSyrPSV7pIESo7I5my33OZS@/1VW1kFdbPrqIIQnK8yLMa8m8UV2X57XqLkeyKMx6IdW0sy23/m5YWkjVqf4tGOQs0ud03qIfWsY3DVueWXI45slOBzvkTm2CCv43NQDlMw7XK7hR/tQhopRqEgWMrU2RZRsxHvCxzMiwd9TmKD5YnvOuknDPf4y3WP4KlFBMQA43cCMV30CXdX2/XPWr7/8A)
This could be smaller if a generic List is considered a valid output (drop the .ToArray() to save 10 bytes).
If the input can also be modified, then passing in a List<int> instead of an array removes the need to initialize the output (comes out at 126 bytes).
Taking this a step further, there doesn't really need to be a return value in this case. Using an Action instead removes the 9 bytes used by the return statement.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 19 bytes
```
®‘©‘÷@+2\⁸żFfṀR$µÐL
```
[Try it online!](https://tio.run/##y0rNyan8///QukcNMw6tBBKHtztoG8U8atxxdI9b2sOdDUEqh7YenuDz//9/QxMTHQVjYzMA "Jelly – Try It Online")
]