[Question]
  [
*(Randomly inspired by <https://mathoverflow.net/q/339890>)*  
*(Related: [1](https://codegolf.stackexchange.com/q/12879/42963), [2](https://codegolf.stackexchange.com/q/89852/42963))*
Given an input list of distinct prime numbers (e.g., `[2, 5, 7]`), and a integer `n`, output all positive integers strictly smaller than `n` that contain only those primes as divisors. For input `[2, 5, 7]` and `n=15` this means an output of `[2, 4, 5, 7, 8, 10, 14]`.
**Further Examples**
```
[list] n | output
[2, 5, 7] 15 | [2, 4, 5, 7, 8, 10, 14]
[2, 5, 7] 14 | [2, 4, 5, 7, 8, 10]
[2] 3 | [2]
[2] 9 | [2, 4, 8]
[103, 101, 97] 10000 | [97, 101, 103, 9409, 9797, 9991]
[97, 101, 103] 104 | [97, 101, 103]
```
**Rules and Clarifications**
* The input list is guaranteed non-empty, but may be only a single element
* You can assume the input list is pre-sorted in whatever way is most convenient
* `n` will always be larger than the largest element in the input list
* Since, e.g., `2**0 = 1`, you can optionally include `1` in your output list
* Input and output can be given by [any convenient method](http://meta.codegolf.stackexchange.com/q/2447/42963)
* You can print the result to STDOUT or return it as a function result
* Either a full program or a function are acceptable
* If applicable, you can assume the input/output integers fit in your language's native `int` range
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/42963) are forbidden
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so all usual golfing rules apply, and the shortest code (in bytes) wins
  
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 6 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
Ç─☼?▬µ
```
[Run and debug it at staxlang.xyz!](https://staxlang.xyz/#p=80c40f3f16e6&i=[2+5+7]+15%0A[2+5+7]+14%0A[2]+3%0A[2]+9%0A[103+101+97]+10000%0A[97+101+103]+104&a=1&m=2)
### Unpacked (7 bytes) and explanation:
```
vf:Fn-!
vf         Filter range [1..n-1]:
  :F         Distinct prime factors
    n-       Remove all in provided list
      !      Is empty?
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~6~~ 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
PmÑʒ›
```
-1 byte thanks to *@ovs* (and *@Grimmy*, who provided [`sиPÑʒ›`](https://tio.run/##yy9OTMpM/f@/@MKOgMMTT0161LDr//9oIx3TWC5DAwA) as 6 bytes alternative initially).
Takes the list as first input, and integer as second. Includes the optional `1` in the output.  
Extremely slow approach (the `[2,5,7], 15` test case already times out).
[Try it online.](https://tio.run/##yy9OTMpM/f8/IPfwxFOTHjXs@v8/2kjHNJbL0AAA) (No test suite, because it's too slow for most.)
**Explanation:**
```
P      # Take the product of the (implicit) input-list
       #  i.e. [2,5] → 10
 m     # Take the (implicit) input-integer to the power this product
       #  i.e. 10 → 10000000000
  Ñ    # Get all divisors of this integer
       # (the bottleneck for larger integers in this approach)
       #  → [1,2,4,5,8,10,16,20,25,32,40,50,64,80,100,125,128,160,200,250,256,320,400,500,512,625,640,800,1000,1024,1250,1280,1600,2000,2500,2560,3125,3200,4000,5000,5120,6250,6400,8000,10000,12500,12800,15625,16000,20000,25000,25600,31250,32000,40000,50000,62500,64000,78125,80000,100000,125000,128000,156250,160000,200000,250000,312500,320000,390625,400000,500000,625000,640000,781250,800000,1000000,1250000,1562500,1600000,1953125,2000000,2500000,3125000,3200000,3906250,4000000,5000000,6250000,7812500,8000000,9765625,10000000,12500000,15625000,16000000,19531250,20000000,25000000,31250000,39062500,40000000,50000000,62500000,78125000,80000000,100000000,125000000,156250000,200000000,250000000,312500000,400000000,500000000,625000000,1000000000,1250000000,2000000000,2500000000,5000000000,10000000000]
   ʒ   # Filter this list of divisors:
    ›  #  Only keep those where the (implicit) input-integer is larger than the divisor
       #  → [1,2,4,5,8]
       # (after the filter, the result is output implicitly)
```
---
**Two faster 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) alternatives:**
```
<LʒfåP
```
Takes the integer as first input, list as second. Includes the optional `1` in the output.
[Try it online](https://tio.run/##yy9OTMpM/f/fxufUpLTDSwP@/zc05Yo20jHVMY8FAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWVC6H8bn1OTIorTDi8N@F@r8z862tBUJ9pIx1THPDZWRyHa0ASZZwzkgBmWMIahARDoACljHUMDQx1LqC4DoDZLc7AQUCo2NhYA).
**Explanation:**
```
<       # Decrease the (implicit) input by 1
 L      # Create a list in the range [1,input-1]
  ʒ     # Filter it by:
   f    #  Get all prime factors of the current number (without duplicates)
    å   #  Check for each if its in the (implicit) input-list
     P  #  And check if this is truthy for all
        # (after the filter, the result is output implicitly)
```
---
Thanks to *@Grimmy*:
```
GNfåP–
```
[Try it online](https://tio.run/##yy9OTMpM/f/f3S/t8NKARw2T//83NOWKNtIx1TGPBQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX6nDpeRfWgLh6VQmhP53j/BLO7w04FHD5P@1h7bZ/4@ONjTViTbSMdUxj43VUYg2NEHmGQM5YIYljGFoAAQ6QMpYx9DAUMcSqssAqM3SHCwElIqNjQUA).
```
G       # Loop `N` in the range [1, (implicit) input):
 Nf     #  Get all prime factors of `N` (without duplicates)
   å    #  Check for each if its in the (implicit) input-list
    P   #  And check if this is truthy for all
     –  #  If it is, output the current `N` with trailing newline
```
[Answer]
# JavaScript (ES6), ~~64 ... 52~~ 50 bytes
Takes input as `(n)(primes)` where *primes* is a set. Outputs by modifying the set.
```
n=>g=(s,q=1)=>{for(p of s)(p*=q)<n&&g(s.add(p),p)}
```
[Try it online!](https://tio.run/##lc/BDoIwDADQu1@xE2nNJEwkhGj5CY/GA4GNSMg2GNGD8dvnguGowZ6atq9pu@peuXq82WmnTSO9Iq@pbAkcH0gglU9lRrDMKOYQ7JYGPOkoasHFVdOARW7x5Z2cGDEtH@wsJ7jsecbzKx6ZApEhhG7Ia6Od6WXcm3aubH6gw2r0Aemf88XaeZGkXCSCF8tlSYi1uMhnG3Ys@Otf/g0 "JavaScript (Node.js) – Try It Online")
### Commented
```
n =>              // n = maximum value
g = (             // g is a recursive function taking:
  s,              //   s = set of primes
  q = 1           //   q = current product, initialized to 1
) => {            //
  for(p of s)     // for each value p in s:
    (p *= q)      //   multiply p by q
    < n &&        //   if the result is less than n:
      g(          //     do a recursive call:
        s.add(p), //       with p added to the set
        p         //       with q = p
      )           //     end of recursive call
}                 //
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~68~~ 65 bytes
```
f=lambda s,n,c=1:n//c*s and f(s,n,s[0]*c)+f(s[1:],n,c)or[c][:c<n]
```
[Try it online!](https://tio.run/##dZBBasMwEEX3PsXglZUOxE4cUpl6UUoXXfUAiiiuIlNDIhtJpimmZ3dHtqEpoQNa6P33ZzHdl/9ozXYc6/JUnd@PFTg0qMqsMOu1WjmozBHqJEAnUrlS7I5@Iitk0FhrhZKiUA9Gjl47/6Yqpx2UIKJEbCTCFkFkCBvJcCF8IQg5wv3CEXYIe0qz3XUcIEmEU3r5jZz/I89ilm7DhwQ@2SnNXOD7JZgUnqc8sEA559ncvnamdn7blSySUVS3FjrbnLVDODXnxiPoSweNgd@TFBHQtL2n29TJH5tNUeWcth5ca70@JiQyKMuwB6GOD@bFdL0vgjjM5e@Dee39AgfyCTxfOq2oXsBARQLxtJoKxifxU2stxfBo3Ke2MRt/AA "Python 3 – Try It Online")
*-3 bytes thanks to @xnor*
The function takes a prime sequence and an integer n as inputs. The output is a list that includes 1.
# Ungolfed:
```
def f(s, n, c=1):
    if not c < n:
       return []
    elif not s:
       return [c]
    else:
       return f(s,n,s[0]*c) + f(s[1:],n,c)
```
[Try it online!](https://tio.run/##dZFBa4MwGIbv/ooXT2bLQauli8zDGDvstB9gwyhpZEIbJYmso@y3uy/qWLeyDzzkeZ83wpf@w791Jh/HvW7QJI7DcKgqY2UEmraB6TwU7mFmQmO1H6xBLSegD4vkrgT1bTj9Nwu/MtzVqbxRDLfhXGelJKbY6LXzr2rntEOFOkrqleTIOeqMYyUZX4hYCEfBcbdwjjXHhtJsfRkHSBLhlL7iSi7@kWcxS/NwIEFMdkozF8RmCSZFFKkILFAhRDa3L52pXVx3JYtkFDWdRW/bo6Z3OLTH1nPoU4/W4Gcl8ya7wdNumuSXzaZo55y29Byd9XqfkMhQVeEejibemmfTD74M4nkuf27Ny@AXeCafwNOp14rqJc5UJBBPV1PB@CR@7KylGA/GvWsbs/EL "Python 3 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 51 bytes
For each prime `x` in the list of primes `p` the expression `mapM((<$>[0..n]).(^))p` computes all powers \$1,x,x^2,\ldots,x^n\$ (where \$n\$ is the second input just used as an upper bound) and then the cartesian product of all these sequences. After that we compute the `product` of all entries of this cartesian product and filter out all that are too large.
This means that it is incredibly slow or might even crash if `n` is large or the list of primes `p` is large, as this cartesian product contains \$(\#p)^n\$ entries.
```
p#n=[k|k<-product<$>mapM((<$>[0..n]).(^))p,k<n,k>1]
```
[Try it online!](https://tio.run/##FcyxCsIwEADQXzlohgRisEJxSTt11C8IEYIKhmuuR3Ju/nvU7U3vlRo@t63nwnsVWJMkd8lNOg80B/ygP3DdH@@7eLWUxFetfwhH5ygap2/GsEVPFpcx9pIywQxcMwkoaP9RgR4MhJOFycI5wjj1Lw "Haskell – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 39 bytes
```
l%n=[k|k<-[2..n-1],mod(product l^k)k<1]
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P0c1zzY6uybbRjfaSE8vT9cwVic3P0WjoCg/pTS5RCEnLlsz28Yw9n9uYmaegq1CQVFmXomCioJCtJGOgqmOgnmsgqqCoel/AA "Haskell – Try It Online")
Checks if `k` is divisible only by primes in `l` by seeing if the product of `l` taken to a high power is divisible by `k`.
[Answer]
# [Python 2](https://docs.python.org/2/), 65 bytes
```
lambda l,n:[k for k in range(2,n)if reduce(int.__mul__,l)**n%k<1]
```
[Try it online!](https://tio.run/##TYrLCoMwFAX3fsXdFBIJYnwgSvslqQRbkxoSrxIMpV@fRrrp5gxzmP1zLBtWUd/u0U3rY57AMRyEBb15sGAQ/IQvRSqG1Gjwag5PRQwehZRrcFIyR/McL/bKx/hejFPAh92nADTJDe7hIJRGUTFoGXQjA95m/9YkS6x/6DPRd@kt@Tn1GZTNFw "Python 2 – Try It Online")
Checks if `k` is divisible only by primes in `l` by seeing if the product of `l` taken to a high power is divisible by `k`.
If `l` can be taken as a list of strings `eval("*".join(l))` [saves 3 bytes](https://tio.run/##TYxNCoMwFIT3nuIhFBIJxfiDaOtJrIuUmhoTnyFNW3r6NNJNN/Mxw8zYj583LILsL8GI9XoTYBh2gwa5OdCgEJzA@0QKhlRJmF7CkDRLj8umkBhKswwP@szH8J6VmYB3cd4rtE9P6Mk6hR4kWYUlD@@YofElDAWDmkEzMuB18u@q6CLLH9pkaJuY5nyXci/k1Rc) over `reduce(int.__mul__,l)` and can be used in Python 3 which lacks `reduce`.
**[Python 3](https://docs.python.org/3/), 64 bytes**
```
def f(l,n,P=1):
 for x in l:P*=x
 n-=1;P**n%n or print(n);f(l,n)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/PyU1TSFNI0cnTyfA1lDTikshLb9IoUIhM08hxypAy7aCSyFP19bQOkBLK081TwEoV1CUmVeikadpDdal@T9NI9pIR8FUR8E8VkfB0ETzPwA "Python 3 – Try It Online")
A function the prints in reverse order and terminates with error.
The recursive solution below would be shorter if `n` itself were included in the list. I tried recursively computing the product of `l` as well, but that was longer.
**62 bytes (non-working)**
```
f=lambda l,n:n*[f]and[n][reduce(int.__mul__,l)**n%n:]+f(l,n-1)
```
[Try it online!](https://tio.run/##TYpNCsMgGAX3OYWbglpbYn4IEXoSEbFVScB8kaCUnt4auunmDfOY@EnLDl0p/hHM9rQGBQYCqPTKgJWg5OFsfjm8QrprveWgNQuEUriAUFePa37jpLyXNTjERTxqiDymK8ScMCFFdgyNDE2KIT42/zZUq@x/mBs5T/Vt@Tn9GbTDFw "Python 2 – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 25 bytes [SBCS](https://wikipedia.org/wiki/SBCS)
```
{⍺{v/⍨⍺>v←∪,∘.×⍨⍵}⍣⍺⊢1,⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v/pR767qMv1HvSuADLuyR20THnWs0nnUMUPv8HSw4NbaR72LgXKPuhYZ6oC4/9MUgKoU0kBKe/sedTU/6l3zqHfLofXGj9omPuqbGhzkDCRDPDyD/xsaKKQpGCkYK5gCAA "APL (Dyalog Unicode) – Try It Online")
**How it works**:
The main idea of this solution is that we take the input primes `⍵`, we prepend 1 to them with `1,⍵` and we multiply these numbers all together a bunch of times, where "a bunch of times" is the `n` input (refered to by `⍺`). This repetition is controlled by `⍣⍺`. What we actually repeat is the inner dfn
`{v/⍨⍺>v←∪,∘.×⍨⍵}`
This dfn takes as `⍺` the input `n` and as `⍵` the multiplications we have so far. Then, `∘.×⍨⍵` multiplies all those accumulated multiplications so far with themselves, into a matrix that looks like a "times table" of `⍵` with itself.
Then `∪,` flattens and removes duplicates and assigns that to `v` with `v←`.
Finally, `v/⍨⍺>v` filters out elements greater than or equal to `⍺`, which is the `n` input.
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 10 bytes
```
…@e⟪ḍ‡⁻!⟫⁇
```
[Try it online!](https://tio.run/##ASoA1f9nYWlh///igKZAZeKfquG4jeKAoeKBuyHin6vigYf//zE0ClsyIDUgN10 "Gaia – Try It Online")
I've never used `‡` with a monad before, it's quite helpful for stack manipulation.
```
…		| push [0..n-1]
@e		| push list of primes
  ⟪    ⟫⁇	| filter [0..n-1] for where the following predicate is true:
   ḍ‡		| the list of prime factors
     ⁻		| minus the list of primes
      !		| is empty
```
[Answer]
# [J](http://jsoftware.com/), 24 bytes
```
(]#~0=1#.(-."1~q:))2}.i.
```
[Try it online!](https://tio.run/##bYwxCsJAEEX7nOKTFEnAHXaSDcksbCVYWdlbiYvaiAcwV19nDWJAB34x77@ZWyqpjggeNTaw8BpD2B72u9Qcq9kGrqgxVPL88G3bPelKqS2K8@lyRweHASMmsAU7GK8ogwge/ijr3n36oInov/q0eBGyMBn1ljU9xFnRXYmIcPYyza28n1od/Fypttqy5tIL "J – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
ṖÆffƑ¥Ƈ
```
[Try it online!](https://tio.run/##AR8A4P9qZWxsef//4bmWw4ZmZsaRwqXGh////zE1/zIsNSw3 "Jelly – Try It Online")
A dyadic link taking the exclusive upper bound as its left argument and the list of primes as its right. Returns a list that includes 1 as well as the numbers only composed of the supplied primes.
An alternative 7 would be `ṖÆfḟ¥Ðḟ`
[Answer]
# [Python 2](https://docs.python.org/2/), 98 bytes
```
lambda a,n:[i for i in R(2,n)if{p for p in R(2,i+1)if(i%p<1)*all(j%p for j in R(2,p))}<=a]
R=range
```
[Try it online!](https://tio.run/##PcqxCsIwEIDhvU9xSyGnGUxUQqV5ia7qcKLRKzENoYuUPHu0Sl3@4eOPr/ExBF2cPRVPz8uVgGQ4HBnckICBA3RCy4Dspvi1uBiv1UcF17FVuCLvRV//ln5ZImJuLZ2rziYK91uJicMITkxa7qXJ0mD1p8ZIUBs1Z5vn7rC8AQ "Python 2 – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-f`](https://codegolf.meta.stackexchange.com/a/14339/), ~~11~~ 8 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
k
è@e!øV
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWY&code=awroQGUh%2bFY&input=MTUKWzIsNSw3XQ)
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-f`](https://codegolf.meta.stackexchange.com/a/14339/), 7 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
©k e!øV
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWY&code=qWsgZSH4Vg&input=MTUKWzIsNSw3XQ)
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-rprime`, 61 bytes
```
->n,l{(2..n).select{|i|i.prime_division.all?{|b,|[b]-l==[]}}}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5PJ6daw0hPL09Trzg1JzW5pLomsyZTr6AoMzc1PiWzLLM4Mz9PLzEnx766JkmnJjopVjfH1jY6tra29n@BQlq0oamOQrSRjgKQMo@N/f8vv6AEqKH4v24R2AgA "Ruby – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 64 bytes
```
\d+
$*
\G1
$.`,$`;
+`,(1+)(\1)*(?=;.* \1\b)
,1$#2$*
!`\d+(?=,1;)
```
[Try it online!](https://tio.run/##RYu7CsJAEEX7@YoRV9jHEHITQwiLWOYnphhFCxsL8f83kyrN4XAfv/f/8320S1yt6atQyKQrKHQmwSoVk4iSoiLleL/VLrNCn4kE4Tz4@GT@8kZQU2uYKg/Ck/BMuB4@utKyA73HyyyMHjvGDQ "Retina 0.8.2 – Try It Online") List includes smaller test cases (`10000` times out because of all the long strings). Takes input in the order `n f1 f2 f3...` (factors do not need to be prime but they do need to be coprime). Output includes `1`. Explanation:
```
\d+
$*
```
Convert to unary.
```
\G1
$.`,$`;
```
Generate a list from 0 to `n-1`, in both decimal and unary.
```
+`,(1+)(\1)*(?=;.* \1\b)
,1$#2$*
```
Repeatedly divide the unary by any available factors.
```
!`\d+(?=,1;)
```
Output the decimal numbers where the unary number has been reduced to `1`.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 10 bytes
```
f!-PThQtUe
```
[Try it online!](https://tio.run/##K6gsyfj/P01RNyAkI7AkNPX//@hoIx1THfNYHUPTWAA "Pyth – Try It Online")
Takes input as `[[primes...], n]`
```
        Ue  # range(0, Q[-1])  (Q is the input, implicit)
       t    #                [1:] -> range(1, Q[-1]), tUe == PSe
f           # filter that on the condition: lambda T:
   PT       # prime_divisors(T)
  -  hQ     #                   - Q[0]
 !          # logical negation (![] == True)
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 27 bytes
```
{grep [*](@^a)**$^b%%*,^$b}
```
[Try it online!](https://tio.run/##bYxNC4JAFEXX@ivuQmNmHFJTS5OgFu1at3FGUNIIskRXof5282NRQYv3ePe8wy2z6r7uixcWOXZ9c62yEhGTZB8nlDEtTnWd8VhLuz5/ViD32yOrKRpVKba1SUS0ZEJSEHExKERrhqpSJy/kRLOWx/PhxGFoNg3Vro9WHB7HRsL20GKM7kw4fA7bGsaV6pfm/tVGRcKZfvMdfDx/IMFm1OxxOUOLNdX8wDc "Perl 6 – Try It Online")
Port of xnor's Haskell solution. Also outputs 1.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~22~~ 20 bytes
```
ＩΦ…²η⬤…·²ι∨﹪ιλ⊙θ¬﹪λν
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwy0zpyS1SCMoMS89VcNIRyFDU0fBMSdHwzMvOae0OLMsFS6TCZTxL9LwzU8pzcnXyNRRyAEpzavUKNRR8MsvgUnk6CjkaUKB9f//0dFAraY6CuaxOgqGprH/dctyEgE "Charcoal – Try It Online") Link is to verbose version of code. Too slow for the larger test case. Explanation:
```
 Φ                      Filter on
  …                     Range from
   ²                    Literal `2` to
    η                   Input limit
     ⬤                  Where all values
      …·                Inclusive range from
        ²               Literal `2` to
         ι              Filter value
          ∨             Either
             λ          Inner value
           ﹪            Is not a divisor of
            ι           Filter value
              ⊙         Or any of
               θ        Input primes
                   ν    Current prime
                ¬﹪      Is a divisor of
                  λ     Inner value
Ｉ                       Cast to string for implicit print
```
Previous faster 22-byte answer:
```
⊞υ¹ＦυＦ×ιθＦ›‹κη№υκ⊞υκＩυ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gtDhDo1RHwVDTmistv0hBo1RTAUyHZOamFmtk6igUakJF3ItSE0tSizR8UouLNbJ1FDI0dRSc80vzSkD6szWBymCGZQMNCyjKBMo4JxYDpTU1rf//j442NDAGWmRgqKNgaR4LYgFB7H/dshwA "Charcoal – Try It Online") Link is to verbose version of code. Output includes `1`. Explanation:
```
⊞υ¹
```
Push `1` to the predefined empty list.
```
Ｆυ
```
Loop over the list, including any items pushed to it during the loop.
```
Ｆ×ιθ
```
Multiply the current item by each prime and loop over the products.
```
Ｆ›‹κη№υκ
```
Check whether the product is a new value.
```
⊞υκ
```
If so then push it to the list.
```
Ｉυ
```
Print the list.
[Answer]
# [C (clang)](http://clang.llvm.org/), 115 bytes
```
#define f(n,l,z){int j,i,k,x[n]={};for(i=x[1]=1;i<n;printf(x[i]+"\0%d ",i++))for(j=z;j--;k<n?x[k]=x[i]:0)k=i*l[j];}
```
[Try it online!](https://tio.run/##dZHRaoMwFIbvfYrgGCTzSBOjFJeGPUgqo1QdUZsVa0EqPrszOodl7cnl9/055M/RP1YH8zVo06BzrU/Z5ZOpRHYBRLDtxWbDIgc9npGFzioXTDmb4c5DPV7b3NqMckCMMkDxvIxSupZCK8XbX2e0ZykcXtIs1yZDOTZQwY10NlSAhhJaZcZQL/LvGmvZKpZIJvTOiPFO0@S4VTrx3D19TZEL2vMIsWYhb6LwfVHuzEerykRa7Z2SUuq3ShWJ6KeKTgdtMEGdk2MWwVIYcOKcr80Fuy4RFoVPEV9IAOyexE@JbYUulP9bRv@2hfdsnPnNCLt7g5A/ncykFtovqbPmWhtEhdMPPw "C (clang) – Try It Online")
A Sieve of Eratosthenes based solution.
(Includes 1 in the output)
Thanks to @ceilingcat suggestion : 
 printf(x[i]+"\0%d ",i++) instead of x[i]&&printf("%d ",i),i++ 
 I suppose it shifts the pointer of the literal but didn't found any documentation, if anyone can give me some insights it would be welcome.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
fȯ¦⁰upŀ²
```
[Try it online!](https://tio.run/##ASEA3v9odXNr//9myK/CpuKBsHVwxYDCsv///zE1/1syLDUsN10 "Husk – Try It Online")
]