[Question]
  [
Two or more positive integers are said to be "[friendly](https://en.wikipedia.org/wiki/Friendly_number)" if they have the same "abundancy". The abundancy of an positive integer \$n\$ is defined as $$\frac {\sigma(n)} n,$$ where [\$\sigma(n)\$](https://en.wikipedia.org/wiki/Divisor_function) is the sum of \$n\$'s divsors. For example, the abundancy of \$30\$ is \$\frac {12} 5\$ as
$$\frac {\sigma(30)} {30} = \frac {1 + 2 + 3 + 5 + 6 + 10 + 15 + 30} {30} = \frac {72} {30} = \frac {12} 5$$
Because \$140\$ has the same abundancy (\$\frac {12} 5\$), we know that \$30\$ and \$140\$ are "friendly". If a number does not have the same abundancy of any other numbers, it is termed a "solitary" number. For example, \$3\$'s abundancy is \$\frac 4 3\$ and it can be shown that no other number has an abundancy of \$\frac 4 3\$, so \$3\$ is solitary.
We can partition the positive integers into "clubs" of friendly numbers. For example, the [perfect numbers](https://en.wikipedia.org/wiki/Perfect_numbers) form a club, as they all have abundancy \$2\$, and solitary numbers each form a club by themselves. It is currently unknown whether or not infinitely large clubs exist, or if every club is finite.
---
You are to take two positive integers \$n\$ and \$k\$, and output \$k\$ numbers in \$n\$'s club. You may assume that \$k\$ will never exceed the size of the club (so \$k\$ will always be \$1\$ for solitary numbers etc.). You may output any \$k\$ numbers, so long as they all belong to \$n\$'s club (note that this means you do not always have to output \$n\$). You may input and output in any [reasonable format and manner](https://codegolf.meta.stackexchange.com/q/2447) - keep your golfing in your code, not your I/O.
**A few remarks**
* You may assume that \$n\$ is known to be either friendly or solitary - you will never get e.g. \$n = 10\$.
* It [has been shown](https://oeis.org/A014567) that if \$\sigma(n)\$ and \$n\$ are co-prime, \$n\$ is solitary, and so, in this case, \$k = 1\$.
* Your answers may fail if values would exceed the limit of integers in your language, but only if that is the *only* reason for failing (i.e. if your language's integers were unbounded, your algorithm would never fail).
* I am willing to offer a bounty for answers that also include a program that aims to be quick, as well as correct. A good benchmark to test against is \$n = 24, k = 2\$ as the smallest friendly number to \$24\$ is \$91963648\$
This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge, so the shortest code in each language wins.
---
## Test cases
Note that the outputs provided are, in some cases, sample outputs, and do not have to match your outputs
```
n, k -> output
3, 1 -> 3
6, 4 -> 6, 28, 496, 8128
8, 1 -> 8
24, 2 -> 24, 91963648
84, 5 -> 84, 270, 1488, 1638, 24384
140, 2 -> 30, 140
17360, 3 -> 210, 17360, 43400
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~11~~ 10 bytes
*-1 thanks to @Jonathan Allan.*
```
1,Æs×ṭʋE¥#
```
[Try it online!](https://tio.run/##y0rNyan8/99Q53Bb8eHpD3euPdXtemip8n@gkInBf2MA "Jelly – Try It Online")
### Explanation
Jelly's `#` parsing is *really* confusing. `#` doesn't consume the first link `1`, since it's a nilad. (This, as it turns out, works really weirdly if you use chain separators; the equivalent code would be `ø1ð,,Æs$ÆḊ¬ð#`.)
The code is essentially parsed from postfix notation to the following, where `[]` represent chains:
```
[1 #(filter=¥[ʋ[, Æs × ṭ] E])]
```
This chain is then applied to the arguments `(n, k)`. The value is first initialized to `n`.
The `#` operation is then used as a dyad, as if it's the `+` in `1+`. It receives `(1, n)` as arguments and starts passing those to its `filter` chain, incrementing the `1` until `k` matches are found. (Since `#` only consumed one link, the last command-line argument is used as the count.)
The filter chain then does this, where `x` is the candidate number:
* `,`: make pair `[x, n]`.
* `Æs`: compute `[sigma(x), sigma(n)]`.
* `ṭ`: make pair `[n, x]`.
* `×`: elementwise multiply, i.e. `[sigma(x)*n, sigma(n)*x]`.
* `E`: see if the values equal. This is pretty clearly true iff `x/sigma(x)=n/sigma(n)`.
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~11~~ 10 bytes
```
↑f¤=oṁ\Ḋ⁰N
```
[Try it online!](https://tio.run/##ASEA3v9odXNr///ihpFmwqQ9b@G5gVzhuIrigbBO////MTQw/zI "Husk – Try It Online")
```
↑f¤=S/oΣḊ⁰N
 f        N  # filter the natural numbers by
  ¤          # combin: '¤fgxy' means 'f(g x)(g y)', where
   =         #  f is '=' equals
    oṁ\Ḋ     #  g is 'oṁ\Ḋ', which parses as:
    o        #   compose 
     ṁ       #    map this & sum the results:
      \      #     reciprocal
       Ḋ     #    over each divisor of argument
        ⁰    #  x is the last input argument
             #  y is the number being filtered (so, each of the natural numbers)
↑            # finally, from the filtered numbers, take 
             # the first n equal to the other input argument.
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~90~~ 79 bytes
```
->n,k{w=0;g=->w{(1..w).sum{|x|w%x<1?x:0}};k.times{g[w+=1]*n==g[n]*w||redo;p w}}
```
[Try it online!](https://tio.run/##BcHdDkAgGADQV3Fj89uKO/l4kNaNoZmJhX1Z9ew5x7zTF1eI9aCr3SFQrqAe0GWMEMzJ/R7OW4@p7dloOxoC38mzHcvtlMASmCw0gBJaFui9WeaTXwmGEFfR0qqR8Qc "Ruby – Try It Online")
[Answer]
# [JavaScript (V8)](https://v8.dev/), ~~91 89 88~~ 85 bytes
*Saved 3 bytes thanks to @tsh*
Expects `(n)(k)`. Prints the numbers.
```
n=>k=>{for(g=x=>{for(q=d=x;--d;)x%d?0:q+=d},i=0;k;q*++i+~g(i)*q*n||print(i)|k--)g(n)}
```
[Try it online!](https://tio.run/##RZDdaoMwFMfvfYpzsUFS4xqTzGYLcVd7ChEqFa0LuOpKEdS9ujtW63Jx@P0/Qjj5ym7Zz6mtLtfgpqfCTrWNnY374rslpe1WamxuOxMEuaHdc/7B3xvf5iOrLDfONDvfr/zfklR01@zqYbi0VX1FNbggoCWp6TiZxANIYD6SQQgpg/0e5GZGDNRqIgqN8g1Bh0JvHf1/cTO1YvD6MJHFgWNL6bkbSZxCSa3WdqgwFI@370V@j8KDjFBKSGGORDhni6ek4txLvRf8hs/sdCYkgZqBg5SCjaGHZdljAk99PTKcboT0SA0UuDhxCEsDYaTTHw "JavaScript (V8) – Try It Online")
### Commented
```
n =>                   // n = positive integer
k => {                 // k = required number of solutions
  for(                 // main loop:
    g = x => {         //   g is a helper function loading sigma(x) in q
      for(             //   loop:
        q = d = x;     //     start with q = d = x
        --d;           //     decrement d and stop when d = 0
      ) x % d ? 0      //     add d to q if d is a divisor of x
              : q += d //
    },                 //   end
    i = 0;             //   start with i = 0
    k;                 //   stop when k = 0
    q * ++i +          //   increment i and test whether:
    ~g(i) * q * n ||   //     sigma(n) * i = sigma(i) * n
    print(i) | k--     //   if so, print i and decrement k
  ) g(n)               //   load sigma(n) in q
}                      // end
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 10 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
µN‚ÂÑO*ËD–
```
Inputs in the order \$k,n\$, outputs the results on separated newlines to STDOUT.
Port of [*@PurkkaKoodari*'s Jelly answer](https://codegolf.stackexchange.com/a/246135/52210).
[Try it online](https://tio.run/##yy9OTMpM/f//0Fa/Rw2zDjcdnuivdbjb5VHD5P//TbjMAA) or [verify almost all test cases](https://tio.run/##yy9OTMpM/V9WGZSg5JlXUFpSbKWQbXt4v04ekFBQ0uFS8i8tgQgr6VQmhP4/tNUv4lHDrMNNhyf6ax3udnnUMPl/7aFt9nqHtv6PjjbUMY7ViTbRMQOShjoWQNJUx8IESBnpGJoYAGljHUNzYzMDsIiRSWwsAA) (times out for `2,24`).
**Explanation:**
```
µ           # Loop while `¾` is not equal to the first (implicit) input-integer:
            # (`¾` is 0 by default)
 N‚         #  Pair the loop-index with the second (implicit) input-integer
   Â        #  Bifurcate it; short for Duplicate & Reverse copy
    Ñ       #  Map both values in the reversed copy to a list of its divisors
     O      #  Sum those inner lists of divisors
      *     #  Multiply it to the pair
       Ë    #  Check if both values in the pair are the same
        D   #  Duplicate this check
         –  #  Pop, and if this is truthy: print `N` with trailing newline
            #  (implicit - Pop, and if this is truthy: increase `¾` by 1)
```
[Answer]
# [R](https://www.r-project.org), ~~74~~ 72 bytes
```
\(n,k,s=\(m,l=1:m)mean(l*!m%%l))while(k)s(F<-F+1)==s(n)&&{show(F);k=k-1}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGGtKLM1LyUnMr45JzSJAUb3aWlJWm6Fjc9YjTydLJ1im1jNHJ1cmwNrXI1c1MT8zRytBRzVVVzNDXLMzJzUjWyNYs13Gx03bQNNW1tizXyNNXUqosz8ss13DSts22zdQ1rIeZtRrFGw8JEx1QTIrNgAYQGAA)
[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 55 bytes
```
f(n,k,i)=while(k,sigma(n)/n-sigma(i++)/i||k-=!print(i))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMGCpaUlaboWN83TNPJ0snUyNW3LMzJzUjWydYoz03MTNfI09fN0IcxMbW1N_cyammxdW8WCosy8Eo1MTU2o9vLEgoKcSo1EBV07BbBcmoaSZ55VTJ5qio6CakpMnn9pCZCnpKOQGG0YCyKNYjWtFdI0kLg6CtHRxjogbrSZjgmIsoDwLEx0TEG0oYmBjhGYYW5sZqBjHBsLtR7mCwA)
This is slow. It tries every positive integer one by one until it finds `k` answers. It takes 3 minutes to calculate `f(24, 2)` on my computer.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 44 bytes
```
ＮθＮη≔⁰ζＷ‹ⅉη«≦⊕ζ¿⁼×ζΣΦ⊕θ∧κ¬﹪θκ×θΣΦ⊕ζ∧κ¬﹪ζκ⟦Ｉζ
```
[Try it online!](https://tio.run/##dY6xCsIwFEVn@xVvfIEIKm5OIgqCLYIuIg6xjTY0TZomUaj47TGoiIO@7cC95928ZG2umQxhqRrvMl8feYuGTJJvLiNPrRVnhQMKXaRrKSQHXHFrcYeEQkkI3JJeypp3cKnyltdcOV68Kj1xApwbz6TFrai5xY7Cxte4ENLFJ1@FOIDCVBVYUci0w1QXXmo0FCryPAovg/lr6H4auo8hzl23Qjncz5h1MX6IE@8hDMeDZBT6F/kA "Charcoal – Try It Online") Link is to verbose version of code. Don't try any of the other test cases on TIO because it's too slow. Explanation:
```
ＮθＮη
```
Input `n` and `k`.
```
≔⁰ζ
```
Start enumerating the club.
```
Ｗ‹ⅉη«
```
Repeat until `k` numbers have been output.
```
≦⊕ζ
```
Increment the number to be tested.
```
¿⁼×ζΣΦ⊕θ∧κ¬﹪θκ×θΣΦ⊕ζ∧κ¬﹪ζκ
```
If it's in the club, then...
```
⟦Ｉζ
```
... output it on its own line.
Save 2 bytes by dropping support for `n=1`:
```
ＮθＮη≔¹ζＷ‹ⅉη«≦⊕ζ¿⁼×ζΣΦθ∧κ¬﹪θκ×θΣΦζ∧κ¬﹪ζκ⟦Ｉζ
```
[Try it online!](https://tio.run/##bY7LCsIwEEXX9itmOYEIKu5ciSgUrAi6EXER22iCafpIohDx22NrRRS8u3OZw9xUsDotmAoh1qWzK5cfeY0VmUTfLBqeGiPPGocUfEM3IRUHXHJjcIeEgiAE7lEvYeX7MNZpzXOuLc86pSdPgPPKMWVwK3Nu0FPYuBwXUtn2KYWpzvBCYVVYTIrMqaItL@QVCp1U/Uj@n@Q/UjNqXUttcT9jxqInh2bII4TheBCNQv@qng "Charcoal – Try It Online") Link is to verbose version of code.
[Answer]
# [Desmos](https://desmos.com/calculator), 122 bytes
```
o->join(o,a),T->T+sign(k-o.length)
n=\ans_0
k=\ans_1
o=[]
T=0
a=\{f(T)=f(n):[T],[]\}
f(K)=\sum_{N=1}^K\{\mod(K,N)=0,0\}N/K
```
Input in the first two lines of the graph (`n` on the first line, `k` on the second)
Output is the value of `o` after the program has completely ran (which is when `T` stops incrementing)
[Try It On Desmos!](https://www.desmos.com/calculator/tn8dbf3sl8)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/yoankvixma)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes
```
µN‚ÑzOËD–
```
[Try it online!](https://tio.run/##yy9OTMpM/f//0Fa/Rw2zDk@s8j/c7fKoYfL//yZcZgA "05AB1E – Try It Online")
Uses that simplification that the "sum of divisors of x, divided by x" is just equal to "sum of reciprocals of divisors of x".  
Apart from this, the rest of the [05AB1E](https://github.com/Adriandmen/05AB1E) nuts & bolts are shamefully stolen from [Kevin Cruijssen's answer](https://codegolf.stackexchange.com/a/246148/95126).
[Answer]
# [Factor](https://factorcode.org/) + `lists.lazy math.primes.factors math.unicode`, 78 bytes
```
[ [ dup divisors Σ swap / ] tuck call '[ @ _ = ] 1 lfrom swap lfilter ltake ]
```
[Try it online!](https://tio.run/##PZBBS8QwFITv/RVz87TVbOu6KIo38eJFPJVFQprQ0Ncm5KVKXfbX@H/8SzXdLn2nb4ZhGJ6RKrowfby/vr3cQzI7xWh16DWhk7HJfbCd5tycc7x4Q2@Vq/VZgJvBGNIwYQRZjpyT/LkgfNAxjqmjj3jIsmOGdEcIFDhduMRuZYH9yrfYl6vYQpQ3qyog7ordrE/ZVKFCPXjU9svyPPHvF/wtPa5xQBxUCyWJcFXhGZ94TKYAmeC6JUXGUtQBFGWrcUh18/InGYIckae0cp13rJffbLRUzfQP "Factor – Try It Online")
## Explanation
Naive algorithm. Takes input as `k n` and returns a `k`-long lazy list containing numbers in the same club as `n`.
```
                           ! 4 6
[ dup divisors Σ swap / ]  ! 4 6 [ dup divisors Σ swap / ]  (push abundancy function)
tuck                       ! 4 [ dup divisors Σ swap / ] 6 [ dup divisors Σ swap / ]
call                       ! 4 [ dup divisors Σ swap / ] 2
'[ @ _ = ]                 ! 4 [ dup divisors Σ swap / 2 = ]
1 lfrom                    ! 4 [ dup divisors Σ swap / 2 = ] L{ 1 2 3 ... }
swap                       ! 4 L{ 1 2 3 ... } [ dup divisors Σ swap / 2 = ]
lfilter                    ! 4 L{ 6 28 496 8128 ... }
ltake                      ! L{ 6 28 496 8128 }
```
[Answer]
# Python, 116 bytes
```
def f(n,k):
 x=lambda n:sum([i for i in range(1,n+1)if n%i==0])/n;i=1
 while k:
  if x(i)==x(n):print(i);k-=1
  i+=1
```
Pretty basic but painfully slow. Calculates the abundancy of each integer from 1 to `n` using the `x` function until the chosen number of matches have been found.
[Answer]
# [Python 3](https://docs.python.org/3/), 109 bytes
```
a=lambda n:sum(-~i*(n%-~i<1)for i in range(n))/n
def f(n,k,i=1):
 if a(n)==a(i):print(i);k-=1
 f(n,k*k/k,i+1)
```
[Try it online!](https://tio.run/##JYoxDoMwDAD3vMJLJZuCUMSW1o9xBWmtgEGBDl369RCJ6U66237HZ7WhFOFZltcoYGH/Ltj9tUG7VTw9xTWDghpksfeERtSbG6cIEa1NrbKn4EAjSG3Mgkphy2pHlUfq2LvrbFJf77unUk4 "Python 3 – Try It Online")
A little longer one-liner,
```
def f(n,k,i=1,a=lambda n:sum(-~i*(n%-~i<1)for i in range(n))/n):print(end=(f"{[i,k:=k-1][0]}\n"if a(n)==a(i)else""));f(n,k*k/k,i+1)
```
Both functions always ends in a error(division by 0) after printing the answers.
[Answer]
# [Haskell](https://www.haskell.org), 85 bytes
```
f=fromIntegral
a n=f(sum[y|y<-[1..n],n`mod`y==0])/f n
n!k=take k[x|x<-[1..],a n==a x]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bU_LCoJAFN37FXeghQNN-epBNO2DoEW0EsGBnAp1DB1JwT9p4yb6ir6gL-hv8oGrZnW453U5j9eFZWEQRfWbENARhtUKtkIC2QzgNug9c8nJ8nvklKdJ3DDBOWWRxkBQrmd57JZVuSauOZkIbyz8ODn5JaWGh6cchCZQSCULAwjdoip6nzduw5RBMZR_YnYV3f896FjrLgqnRAO45fIg052AEWSX5A66jUys4ufIUfLL1t8s_FcsB1nqiINmSsF0jDaibDMX9txANu4n1XWPPw)
`!` is the infix function that implements the friendly club function.
Some testcases are commented out because this is very slow.
-3 bytes from caird.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 99 bytes
```
d;c;s(n){for(d=c=n;--d;)c+=n%d?0:d;d=c;}i;f(n,k){for(i=1;k;++i)s(n)*i-n*s(i)?:printf("%d ",i,--k);}
```
[Try it online!](https://tio.run/##bZThjqIwEMe/71NMSEyolizQAmqX88Nln2I1G1Nwl3BXFyE5c4ZXP28qFXCLURxnfjPzZ@govQ8pr9dMSFG7ilwOx5ObpTJVwvMyQeQiVbNs468zgV7RFuLgKlp2XJEGohSLRUF06rzw1Lx2C7JZf50K1RxcZ5aBQwvqeSUR7RV98HtfKJfA5QnwpR1NXjfv6m0HKVwYhZjCEt@cQsB9vCQsxq@Qt@Ixo@wyAgoapRAhRAELhCMyP3/lssmzwJSfCIVdCNuG2JevdP8gXE6QrCOnQtyEUEqYaNV8icWCmC21dLbkEzmR0XTD/Qkg7oAwGMbAGfen0MSg2H8VrGIW85HKeY91VD8UOgxhMNlg8sGMBjMezGRCyv1R1sXf/Hhw@2bk2Xjmg4vCNyq0qdCmmE0xm@I2xW0qsqnIpmKbim0qsamEmBHJo6obkJ/70xyvuSzzUzcnZ3t@Dbfn1U/8RA6F8W/mmGzcNXD1lAuV5WdM84UxX76LsDUQ8CAQgFuqM8itYLd@92ensKJZwxuzEw/h8h4urfCw5xRw170fuO6gKOC694z@v3hw3I7Lu246OjQTjfHgjhiL6IdSdQOpcBhYVt9pRUZ3@KCznmWosNroSa@drXo11ddaeP5W7UY6W@s2t8ox8fapvf6Th1/7j/rq/fkP "C (gcc) – Try It Online")
[Answer]
# [Wolfram Language(Mathematica)](https://www.wolfram.com/wolframscript/), 112 bytes
Golfed version. [Try it online!](https://tio.run/##XctLC4JAFIbhfb/CZekB85JFNlDQJigICloMg4x5O5ijTNZG9K9PuhCk5fec9xS8zuKC1/jkKqEiAC0P2JaoSxl9XjFtOISAxAJJmrYFTo74xXcpb5gWnFogmCn8R4Z9eo5FWmd7ucsh/M@QmeifEsoJCUF2h6qKRXQvO2Q@GgbzJVOzhDqgWcw0rxJF3U8PNHcyN9PrXE@o7YJmj6IvhqSX1eTFcpeTZIC14/XkjKR@)
```
Module[{a,b,i=1,r={}},a=DivisorSigma[1,n]/n;While[Length@r<k,b=DivisorSigma[1,i]/i;If[a==b,r~AppendTo~i];i++];r]
```
Ungolfed version. [Try it online!](https://tio.run/##bY27asNAEEX7/YpbJvKCLEt@EEdFwI3BgUAMKZbFrKPXoGhl1koao29XZgUJKlzNzD1zZhrTVXljOvo0w1Aoe5KoTxpPKV7b7PsrVzcjcZYgpIgkHJdb30sBGG539EPX1r1T2RjF2OrQbpl9VMTqIbdlVymn8YzaKzjfcUiH5B3sC8U3U//t5XLJbXZslfNcj5hmMy5j74QWQhQqloh0GL45sh2PK4lkMm6m9CEo1CKRWPwlwaNf4WQ5UaJkPlnxwTpecRT/R2IYfgE)
```
f[n_, k_] := Module[{a, b, i = 1, r = {}},
  a = DivisorSigma[1, n]/n;
  While[Length[r] < k,
   b = DivisorSigma[1, i]/i;
   If[a == b, AppendTo[r, i]];
   i++
  ];
  r
]
f[3, 1]//Print
f[6, 4]//Print
f[8, 1]//Print
(*f[24, 2]//Print*)
f[84, 5]//Print
f[140, 2]//Print
f[17360, 3]//Print
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, 17 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
@â x÷U ¶Xâ x÷X}jV
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=QOIgePdVILZY4iB491h9alY&input=NiA0)
]