[Question]
  [
#### Task
[FizzBuzz](https://codegolf.stackexchange.com/questions/58615/1-2-fizz-4-buzz), but instead of 3 and 5, you'll take the numbers and corresponding strings as input.
You can assume all inputted numbers are coprime (and \$\ge 2\$). You'll receive one or more numbers, and a string to print with each of them. The normal FizzBuzz would be something like `[[3, "Fizz"], [5, "Buzz"]]`, but you could also receive something like `[[2, "Quux"]]` or `[[2, "a"], [5, "b"], [7, "c"], [33, "d"], [529, "e"]]`.
For output, you'll have two options:
* Print this modified FizzBuzz infinitely
* Take a number as input, and return the first \$n\$ lines
You *must* return output with newline separators. An array of lines is not acceptable.
#### Details
To clarify exactly what this should look like, this is the process to determine what the \$n\$th line should look like (first line is always \$1\$):
1. For each of the inputted numbers \$n\$ is divisble by, append the corresponding string to the output (for example, \$15\$ would result in `"Fizz" + "Buzz" = "FizzBuzz"` for normal FizzBuzz)
2. If \$n\$ is not divisble by any of the numbers (i.e., the line is still empty), default to \$n\$
For example, the first 100 lines of the sample input `[[4, "Foo"], [7, "Bar"], [9, "Baz"]]` are:
```
1
2
3
Foo
5
6
Bar
Foo
Baz
10
11
Foo
13
Bar
15
Foo
17
Baz
19
Foo
Bar
22
23
Foo
25
26
Baz
FooBar
29
30
31
Foo
33
34
Bar
FooBaz
37
38
39
Foo
41
Bar
43
Foo
Baz
46
47
Foo
Bar
50
51
Foo
53
Baz
55
FooBar
57
58
59
Foo
61
62
BarBaz
Foo
65
66
67
Foo
69
Bar
71
FooBaz
73
74
75
Foo
Bar
78
79
Foo
Baz
82
83
FooBar
85
86
87
Foo
89
Baz
Bar
Foo
93
94
95
Foo
97
Bar
Baz
Foo
```
#### I/O
You can take input in any reasonable format. This includes dicts of numbers and their strings, a single list of pairs (like in the examples), two lists (one with numbers and ones with pairs), or similar.
For instances where there's two strings being appended, such as `FooBar` in the example above, any order is acceptable (`BarFoo` is also fine).
#### Other
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes (per language) wins!
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
⁴ḍTị⁵ȯ)Y
```
[Try it online!](https://tio.run/##y0rNyan8//9R45aHO3pDHu7uftS49cR6zcj///8bGvyPNtYx1THXMTTUMTSO/R@t5JZZVaWko@RUCqbc8vNBnMQiMFmlFAsA "Jelly – Try It Online")
Full program that takes \$n\$, the list of numbers \$L\$ and the list of strings \$S\$ as command line argument, and returns a newline separated string
## How it works
```
⁴ḍTị⁵ȯ)Y - Main link. Takes n on the left, L as ⁴ and S as ⁵
      )  - Over each integer 1 ≤ i ≤ n:
⁴ḍ       -   Map each element in L to 1 if i is divisible by it, else 0
  T      -   Indices of 1s
   ị⁵    -   Select the elements of S at those indices
     ȯ   -   If this is the empty list, replace it with i
       Y - Join on newlines
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 29 bytes
```
{{$[a:&~x!'y;,/a;y]}[x]'1+!y}
```
[Try it online!](https://ngn.bitbucket.io/k#eJxLs6quVolOtFKrq1BUr7TW0U+0roytja6IVTfUVqys5eJKi9ZQcsusqlKyVnIqBVKaisYKptaGprEQmfx8kERiEZgEyZoomCtYWhsaGMRycQEA7pwYsQ==)
Takes a dict with (string, number) pairs.
## Explanation
```
{{$[a:&~x!'y;,/a;y]}[x]'1+!y}
                        1+!y  range 1..y
                       '      for each number
                    [x]       with x as constant first argument:
 {$[              ]}           if:
        x!'y                    the values of x mod y
       ~                        logical NOTed
      &                         filter out keys which have truthy values
    a:                          store in a
            ;,/a                return a if non-empty
                ;y              otherwise return number y
```
[Answer]
# [Haskell](https://www.haskell.org/), 69 bytes
```
[]%n=show n
x%_=x>>=id
f a=unlines[[y|(x,y)<-a,mod i x<1]%i|i<-[1..]]
```
[Try it online!](https://tio.run/##LcfBCoMgGADge0/xExMSLBZjByE77LAX2FFkCBn9ZDpmMYve3TXY7fsGHUZjbUpSESfC4D/gskieIratwC7rQYvFWXQmSLnuRWQrbUrNJt8BQmxqRXDHppR1VSmVJo0OBLyW@TG/4QSzHg1wzg/2IIsLg/yO25ZTBsX1yG35pz7/5v2UU5W@ "Haskell – Try It Online")
`f [(3, "Fizz"), (5, "Buzz"), (10, "Boom")]` is an infinite string with newlines in it.
[Answer]
# [JavaScript (V8)](https://v8.dev/), 59 bytes
Prints the sequence forever.
```
a=>{for(k=0;++k;)print(a.map(([m,s])=>k%m?'':s).join``||k)}
```
[Try it online!](https://tio.run/##HcbdCsIgGADQVxlCzI@ZdBH0M1zQRS8hwmRkOKef6NhFrWe32Lk6o150HpKN8345FyOKFt3HYKJOHNqmcS3EZMNMNfc6Uio9ywpE53b@VtfXDHxEG/p@XR18y4Ah4/TkE76ooVIeWUUeiESxSp7@v@u0/bL9TZQCKD8 "JavaScript (V8) – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 8 bytes
```
ƛ¹Ḋ⁰*∑∴,
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C6%9B%C2%B9%E1%B8%8A%E2%81%B0*%E2%88%91%E2%88%B4%2C&inputs=100%0A%5B3%2C%205%2C%207%5D%0A%5B%22Fizz%22%2C%20%22Buzz%22%2C%20%22Joe%22%5D&header=&footer=)
Since y'all complaining about flags, I'll give you a tie with jelly.
Expects `L`imit, `D`ivisors, `S`trings
## Explained
```
ƛ¹Ḋ⁰*∑∴,
ƛ        # for each n in the range [1, L]:
 ¹Ḋ      #     Push n % D == 0 (epicly vectorised)
   ⁰*    #     Push ^ * S (which is vectorised python string multiplication) 
     ∑∴  #     Push max(sum(^), n)
       , #     and print ^ with a newline
```
This would be 7 with the `j` flag 
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-R`](https://codegolf.meta.stackexchange.com/a/14339/), 14 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
õ@VËÌpXvDÎÃ¬ªX
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVI&code=9UBWy8xwWHZEzsOsqlg&input=MTAwCltbNCwgIkZvbyJdLCBbNywgIkJhciJdLCBbOSwgIkJheiJdXQ)
```
õ@VËÌpXvDÎÃ¬ªX     :Implicit input of integer U & array V
õ                  :Range [1,U]
 @                 :Map each X
  VË               :  Map each D in V
    Ì              :    Last element
     p             :    Repeat
      Xv           :      Is X divisible by
        DÎ         :      First element of D
          Ã        :  End map
           ¬       :  Join
            ªX     :  Logical OR with X
                   :Implicit output joined with newlines
```
[Answer]
# [Perl 5](https://www.perl.org/), 56 bytes
```
sub{say join('',map$.%$$\_[0]?'':$$_[1],@_)||$.while++$.}
```
[Try it online!](https://tio.run/##K0gtyjH9r5Jm@7@4NKm6OLFSISs/M09DXV0nN7FARU9VRSU@2iDWXl3dCsQyjNVxiNesqVHRK8/IzEnV1lbRq/1vzaWmkqYRbayj7pZZVaUeqxNtqqPuVApialr//5dfUJKZn1f8X9e3zFTP0AAA "Perl 5 – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 19 bytes
```
Ｅθ∨⭆η⎇﹪⊕ι§λ⁰ω§λ¹Ｉ⊕ι
```
[Try it online!](https://tio.run/##XYu9CsIwFEZf5ZLpBiK0IIg4qSB0KAq6hQwhCbaQJnqNvy8f0276Tecc@EynyUTtcz5QHxK2@oJXAXvCYyrhPHon4OQoaHpjG@3dR2yCITe4kJzFngtYpyZY90IvoCr6/Ck156Vt9S39/catcpZ1VQmQci6A7WJkqsii8EbTxMuJP0wplWcP/wU "Charcoal – Try It Online") Link is to verbose version of code. Prints the first `n` terms. Explanation:
```
 θ                  Input `n`
Ｅ                   Map over implicit range
    η               Input list of pairs
   ⭆                Map over pairs and join
        ι           Outer index
       ⊕            Incremented
      ﹪             Modulo
         §λ⁰        First element of pair
     ⎇              If non-zero then
            ω       Empty string
             §λ¹    Else second element of pair
  ∨                 Logical Or
                  ι Current index
                 ⊕  Incremented
                Ｉ   Cast to string
                    Implicitly print on separate lines
```
Note: Using trunk Charcoal (not available on TIO) this would be only 15 bytes:
```
Ｅθ∨⭆η⎇﹪⊕ιμωλＩ⊕ι
```
Explanation: Takes the input as a dict, which means that iterating over it populates the loop variables directly without having to index into the pairs.
[Answer]
# [R](https://www.r-project.org/), ~~76~~ 64 bytes
*-12 bytes thanks to [@Dominic](https://codegolf.stackexchange.com/users/95126/dominic-van-essen)*
```
function(N,S)repeat{F=F+1;cat(F[all(k<-F%%N)],S[!k],"
",sep="")}
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP0/DTydYsyi1IDWxpNrN1k3b0Do5sUTDLToxJ0cj20bXTVXVTzNWJzhaMTtWR4lLSac4tcBWSUmz9n@aRrKGiY65jqWmTrKGklt@vpKOklNiEZisUtLU/A8A "R – Try It Online")
Takes vectors of `N`umbers and corresponding `S`trings.
Outputs infinitely.
[Answer]
# Python 2, 63 bytes
```
def f(k,i=1):
 print''.join(y*(i%x<1)for x,y in k)or i;f(k,i+1)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728oLIkIz_PaMGCpaUlaboWN-1TUtMU0jSydTJtDTWtuBQKijLzStTV9bLyM_M0KrU0MlUrbAw10_KLFCp0KhUy8xSyNYHsTGuwFm1DTYgxq9I0MvMKSks0NKECC26aRkcb6SgoJSrF6ihEmwJZSWCWOZCVDGYZGwOZKRBpI0sgO1UpNhaiGwA)
-1 bytes thanks to @dingledooper
-3 bytes thanks to @pxeger
[Answer]
# [Java (JDK)](http://jdk.java.net/), 109 bytes
```
l->{for(int i=1;;i++){var s="";for(var e:l)if(i%e.getKey()<1)s+=e.getValue();System.out.println(s==""?i:s);}}
```
[Try it online!](https://tio.run/##ZY9BS8NAEIXv@RVDQNi17UJBELtJBEVBtKeCl@JhTTdh4mY37E4CteS3xyQVLHh833vzZqZSnVpVh68B68Z5gmrUoiU04lpG/1jR2pzQ2QszkCLMLzJb1QhtyR9llBsVAmwVWjhFAE37acbo70Tn8AD16LEdebTl/gOULwOfowCPzoa21j55w0DJVPo0lSYvlnSp/fI8lGUZFOlgVtmpcJ6hJcB0LSUuFvzUKQ8hjWM5WZPQG8OxYHilRanpVR8ZT9Y8LNJZvyvTasbl7hhI18K1JJpxBxnLQjrW3OMmcNn3g5wPLITKc90Qmw4UrmDz0@xmCfGzczFfwhncjuBB@T9wN4PvmHM@NfVRP/wA "Java (JDK) – Try It Online")
## Notes
The `s==""` works here because of the constants pool: the two references to the empty string are actually one reference and have the same address in memory. `s==new String("")` wouldn't have worked for instance.
## Credits
* 3 bytes saved thanks to [AZTECCO](https://codegolf.stackexchange.com/users/84844/aztecco)
[Answer]
# [Julia 0.7](http://julialang.org/), 59 bytes
```
N\d=1:N.|>n->println((a=prod(p->p[2]^(n%p[1]<1),d))>""?a:n)
```
[Try it online!](https://tio.run/##yyrNyUw0///fLybF1tDKT6/GLk/XrqAoM68kJ09DI9G2oCg/RaMAKBRtFBunkadaEG0Ya2OoqZOiqWmnpGSfaJWn@V/DRMtcy1LbUFMhRiHaxNZOyS0/X0nHHMhwSixS0rEEM6qUYv8DAA "Julia 0.7 – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 65 bytes
```
f=lambda a,n=1:print(''.join(j*(n%i<1)for i,j in a)or n)+f(a,n+1)
```
[Try it online!](https://tio.run/##HcvBCsIwDADQXwkFWeKKUBTE4S4e/InSQ0SKKZqMsov@fC27vctbvuvL9Nhant/8eTwZ2OscpqWKrjgMh2KiWPaoO7kGylZBfAFRYOpWGjP2MQZqGWM8eXB3M5c8xHP3jevmy@afS4naHw "Python 3 – Try It Online")
-1 byte thanks to MarcMush
[Answer]
# [J](http://jsoftware.com/), 48 bytes
```
1 :'(|:@([:(,0=+/)0=u|/]);@#"1(,"#:<@":"+))1+i.'
```
[Try it online!](https://tio.run/##VcsxC8IwEAXgvb/iTMHL0ZgmllK8WgkVnMTBtUQRsahLQXCR4l@PbTeH9@Dx@J5hNeOsAA8GzmMiobGFigFBDZuHLDRsj/tdsMAoe3ayYalMlaRkqnefeipdLKxUIua1EywSIps8NAaKDrWGiW3Y@eYferpd750bsFSjIzqxtDnNLUbjA8vcgMwghwJa@gLuug5LrC@vqT8Yfg "J – Try It Online")
This was bizarrely difficult to golf in J.
[Answer]
# [Bash](https://www.gnu.org/software/bash/), ~~100~~ ~~80~~ 75 bytes
*-20 bytes thanks to [@Dude coinheringaahing](https://codegolf.stackexchange.com/users/66833/dude-coinheringaahing)*
*-5 bytes and extra readability thanks to [@Jonah](https://codegolf.stackexchange.com/users/15469/jonah)*
```
for((i=1;;i++));{
o=
for a;{((0==i%${a% *}))&&o=$o${a#* };}
echo ${o:-$i}
}
```
[Try it online!](https://tio.run/##DchBCoQwDEDRfU8RmCqtIuiMbibkMK1MMauA4saSs2e6@ryf03WYFTlDYFoQeRxjxOqEXJuQsIYwE3Hna@pg0Bj7XshL42sARXW//RDwVb6TZ3VqZh8o/Dy2Qb5blhmKiK1vyOn8Aw "Bash – Try It Online")
Takes arguments as strings in the form '$num $str' and uses variable expansion to split them out into their component parts. Outputs infinitely.
I'm pretty sure this one has lots of potential for further golfing, but I'll take an even 100 for my first submission.
[Answer]
# [Scala](http://www.scala-lang.org/), 94 bytes
```
b=>1 to _ map(x=>println(Seq(b.collect{case(k,s)if x%k<1=>s},Seq(x))maxBy(_.size)mkString ""))
```
[Try it online!](https://tio.run/##LY5NCwIhFEX38yseA4GCDQ0EUaTQLIIWraJVRDiTEzaOWkpY0W83@1jd87gH7nMNVzya@iwaD2suNYjghT46WFgLz@zGFbSz1NjdSnsCG3@V@rQHyiDdn9hqmTLWlJXgDRyg5xYFymwSvdJoIy6oLhqjVJp4NtwJ1BGHZQth0M1LytyLfJyAcc9DdUeHwsmHwH3324I8xzhmLUo/oDEMGeRLY3ICky9X/Jp4@udHclE5GuHsFd8 "Scala – Try It Online")
Outputs the first n lines of the sequence.
```
b => //A Map with the keys being divisors (4, 7, 9) and the values being strings ("Foo", "Fizz", etc.)
1 to _ //Make a range to n
 map(x=> //For each x in the range, output either "x" or a string made from its divisors
  println( //Print with newline
   Seq(   //Make a Seq with the two alternatives ^
    b.collect{ //The Fizz, Buzz, FizzBuzz alternative
     case(k,s) //For every divisor k and its accompanying string s,
      if x%k<1 //If k divides x
      =>s},    //Add s to this alternative
    Seq(x)  //The second alternative is just the number itself
   ) maxBy(_.size) //Find the alternative with more elements (if both have 1, the first is chosen)
    mkString ""  //Join into a single string
  )
 )
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
∞ε¹ÖÏJy‚õKн,
```
Integers and strings as two separated input-lists.  
Outputs the infinite sequence.
[Try it online.](https://tio.run/##yy9OTMpM/f//Uce8c1sP7Tw87XC/V@WjhlmHt3pf2Kvz/3@0iY65jmUsV7SSW36@ko6SU2IRmKxSiv2vq5uXr5uTWFUJAA)
**Explanation:**
```
∞            # Push an infinite positive list: [1,2,3,...]
 ε           # Foreach `y` over these integers:
  ¹Ö         #  Check for each integer in the first input-list whether it divides the
             #  current integer
    Ï        #  Get the strings of the second (implicit) input-list at the truthy indices
     J       #  Join this list of strings (it's now "" if none were divisible)
      y‚     #  Pair it with the current integer `y`
        õK   #  Remove empty strings from this pair
          н  #  Pop and leave the first item
           , #  And print it with trailing newline
           
```
[Answer]
# [CSASM v2.5.1](https://github.com/absoluteAquarian/CSASM/releases/tag/v2.5.1), 317 bytes
```
func a:
.local a : i32
push 1
add
pop $3
pop $2
dup
len
pop $4
pop $1
lda 1
.lbl a
push 0
pop a
push -1
pop $5
push $a
push 1
sub
brfalse c
.lbl b
inc $5
push $5
push $4
sub
brfalse c
push $a
push $1
ldelem $5
rem
brtrue b
push 1
pop a
push $2
ldelem $5
print
br b
.lbl c
push a
brtrue d
push $a
print
.lbl d
push '\n'
print
inc $a
push $a
push $3
sub
brtrue a
ret
end
```
A function named `a` which expects an `~arr:i32` for the values, an `~arr:str` for the names and an `i32` representing \$n\$ on the stack, pushed in that order specifically.
**Explanation:**
```
func a:
    ; Used as the flag for if a string was printed
    .local a : i32
    
    ; stack: [ values array, strings array, amount to print ]
    push 1
    add
    pop $3
    pop $2
    ; Duplicate "values array", get its length and store it into $4
    dup
    len
    pop $4
    pop $1
    ; $1 = values, $2 = strings, $3 = final number
    ; Initialize $a to 1
    lda 1
    .lbl a
        ; Reset the "string printed" flag
        push 0
        pop a
        
        ; Reset the "numbers array" iteration
        push -1
        pop $5
        ; If $a == 1, skip to the end
        push $a
        push 1
        sub
        brfalse c
        .lbl b
            inc $5
            push $5
            push $4
            sub
            brfalse c
            ; Loop through each value in the numbers array and check if a$ % them is zero
            ; If they are, print that string
            push $a
            push $1
            ldelem $5
            rem
            brtrue b
            
            ; Modulo was zero
            push 1
            pop a
            push $2
            ldelem $5
            print
            br b
    .lbl c
        push a
        brtrue d
        ; Print the current number
        push $a
        print
    .lbl d
        ; Print the newline
        push '\n'
        print
        ; Loop while $a != $3
        inc $a
        push $a
        push $3
        sub
        brtrue a
    ret
end
```
---
**Sample Program:**
```
func main:
    push $i32:[3,5]
    
    push 2
    newarr str
    pop $a
    push $a
    push "Fizz"
    stelem 0
    push $a
    push "Buzz"
    stelem 1
    push $a
    push 30
    call a
    ret
end
; "func a" would be defined here
```
[Answer]
# [Python 3](https://docs.python.org/3/), 122 bytes
```
exec("g="+input())
n=1
while 1:
 b=1
 for k,v in g:
  if n%k<1:
   print(v,end='')
   b=0
 print(n)if b else print()
 n+=1
```
Input:
```
((4, "Foo"), (7, "Bar"), (9, "Baz"))
```
[Try it online!](https://tio.run/##LYrLDoIwFAX3/YqTJobe0IWNJkZjNy78D9ECDeSWYMXHz9dC2M2ZM8M3toF3KbmPuyvZWFl6Hl5REQm2Rrxb3zuYk0CVF@owotMTPKPJDr4Gb7rz/APD6DmqSTt@2KKgWVV2K1bPlOMKrn@61eSCS2tSUmqvIa8hSNJQh8yX27jwceGfJPoD "Python 3 – Try It Online")
Fairly obvious way of going about the challenge. Using a tuple of tuples saves 1 byte over a dict. Looking at the other python submissions, I realize I missed a lot of optimizations. Lessons to bring to the next code golf, I hope.
[Answer]
# [CJam](http://sourceforge.net/projects/cjam/), ~~36~~ 35 bytes
```
q~{)1${\_@~;%!},_@aa?{1=}%:+oNo}%];
```
[Try it online!](http://cjam.aditsu.net/#code=q%7E%7B%291%24%7B%5C_%40%7E%3B%25!%7D%2C_%40aa%3F%7B1%3D%7D%25%3A%2BoNo%7D%25%5D%3B&input=%5B%5B4%20%22Foo%22%5D%20%5B7%20%22Bar%22%5D%20%5B9%20%22Baz%22%5D%5D%20100)
**Explanation**
```
q~                                       read the factor array and upper bound in one go
  {)                            }%       for each i from 1 to n
    1${       },                          get all the input factors i contains
       \_@~;%!                              by checking i mod f = 0 for each input factor f
                _@aa?                     if there *are* factors in i,
                                            keep the relevant factors [[f, "Foo"], ...]
                                            otherwise keep the number in the form [[i]]
                     {1=}%                keep the 2nd element in each subarray
                                            this is the texts ["Foo","Bar","Baz",...]
                                            or just [i] if there were no input factors
                          :+              sum them all (concatenating texts together)
                            oNo           print in the required format
                                 ];       clean up
```
**(-1 byte)** *dropping `,`: CJam automatically turns a number `n` into `[0, n)` when you map using `%`*
---
**Possible Changes**
**(-2 bytes)** *using `p` instead of `oNo` but this prints `"Foo"`/`"BarBaz"` instead of `Foo`/`BarBaz`*  
**(-2 bytes)** *using `n` instead of `oNo` but this feature isn't in any releases (and most likely will never be)*
]