[Question]
  [
Write the shortest program that prints the sound my alarm clock makes, and stops after an inputted number of `beep`s.
For reference, here is the sound my alarm makes:
```
beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeep
```
Basically `beep`, `beepbeep`, `beepbeepbeep`, and `beepbeepbeepbeep` repeated 5 times each with spaces in between, followed by a `beepbeep...beep` which is 25 `beep`s long with no spaces in between (does `beep` still sound like a word to you?).
Your program should take a number as input (assume it's between 0 and 75), and stop printing after that many `beep`s.
**Note:** Your program should stop after that many beeps, not after that many groups of beeps. For example, `7` will return `beep beep beep beep beep beepbeep`.
Whitespace in between `beep`s must follow the exact pattern above, although any trailing whitespace or unsuppressable output from your compiler or interpreter is allowed.
Test cases:
```
3   beep beep beep
0   
1   beep
7   beep beep beep beep beep beepbeep
8   beep beep beep beep beep beepbeep beep
55  beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeepbeep
67  beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeep
```
This is code golf, so the shortest answer in bytes, per language, wins.
  
[Answer]
# JavaScript (ES7), ~~55~~ 54 bytes
```
f=n=>n?f(n-1)+'beep'+[" "[n>50|n%~~(n**=.4)^52%~n]]:''
```
[Try it online!](https://tio.run/##Dc27DoIwFADQna@4IZC2UAioFaMpTq7@ANaAWHyE3BIwLgi/XtnOdt7Vtxrq/tV9IjR3bW0jUeZ4bChGKQvJTeuOhIULboG5SH7ozzPFIJDxhl3Fyp9RqT0h9lCsOSQcUg4Zhx0HIThsMxU3pj9V9ZMiyBxGB6A2OJhWx6150PIMErwRpwt641KyBSVzJmb/ "JavaScript (Node.js) – Try It Online")
### How?
Given \$1\le n< 50\$, we want to know the number of consecutive beeps that are expected in this part of the sequence. The exact value is given by:
$$\left\lfloor\sqrt{\frac{2n}{5}}+\frac{1}{2}\right\rfloor$$
which is a slightly modified version of [A002024](https://oeis.org/A002024).
But in practice, we only need an exact value on the boundaries of the runs of beeps and we can deal with a few off-by-one errors. That's why we instead compute the following approximation:
$$k=\left\lfloor n^{2/5}\right\rfloor$$
We need to insert a space whenever one of the following conditions is satisfied:
* \$k=1\$ and \$n\bmod 1=0\$ (the 2nd part being always true)
* \$k=2\$ and \$n\bmod 2=1\$
* \$k=3\$ and \$n\bmod 3=0\$
* \$k=4\$ and \$n\bmod 4=2\$
All the above conditions can be merged into:
$$(n \bmod k) = (52 \bmod (k+1))$$
\$52\$ being the smallest integer \$x>0\$ such that \$x\bmod 3=1\$, \$x\bmod 4=0\$ and \$x\bmod 5=2\$.
We need an additional test for \$n\ge50\$, where all remaining beeps are concatenated together. Otherwise, unwanted spaces would be inserted, starting at \$n=54\$.
Hence the final JS expression:
```
n > 50 | n % ~~(n **= 0.4) ^ 52 % ~n
```
which evaluates to `0` when a space must be inserted.
---
# JavaScript (ES7), 55 bytes
A simpler approach using a lookup bit mask.
```
f=n=>n?f(--n)+'beep'+(0x222222492555F/2**n&1?' ':''):''
```
[Try it online!](https://tio.run/##HcbdCoIwGIDhc6/iO5C26TRdLfthelSH3UAFmm39IN9EIwLx2pf0wgPvq/pUfd0923eE9qadMwpVjoWhUYQsJFetWxLS5Cv@LTdCSnmYiyDAWVoQIFtC2MTtTgsOCYeUQ8ZhzUFKDqvsEhvb7av6QRFUDoMHUFvsbaPjxt5peQQF/oDjGf3BUGTTlMwbmfsB "JavaScript (Node.js) – Try It Online")
[Answer]
# x86-16 machine code, IBM PC DOS, ~~58~~ ~~54~~ 53 bytes
Binary:
```
00000000: a182 0086 e02d 3030 d50a 7423 95b8 2009  .....-00..t#.. .
00000010: b305 b101 8bf1 ba30 01cd 2183 fe05 740c  .......0..!...t.
00000020: e20a 4b75 03b3 0546 8bce cd29 4d75 eac3  ..Ku...F...)Mu..
00000030: 6265 6570 24                             beep$
```
Listing:
```
A1 0082         MOV  AX, WORD PTR [82H] ; command line AL = first char, AH = second char 
86 E0           XCHG AH, AL             ; endian convert 
2D 3030         SUB  AX, '00'           ; ASCII convert 
D5 0A           AAD                     ; BCD to binary convert 
74 23           JZ   EXIT               ; handle 0 input case 
95              XCHG AX, BP             ; Beeps Counter (BP) = user input 
B8 0920         MOV  AX, 0920H          ; AH = 9, AL = ' ' 
B3 05           MOV  BL, 5              ; Space Counter (SC) = 5 
B1 01           MOV  CL, 1              ; Beeps per Space Counter (BpSC) = 1  
8B F1           MOV  SI, CX             ; Beeps per Space (BpS) = 1 
BA 0130         MOV  DX, OFFSET BEEP    ; DX pointer to 'beep' string 
            BEEP_LOOP: 
CD 21           INT  21H                ; display beep
83 FE 05        CMP  SI, 5              ; exceeded 50 beeps? 
74 0C           JZ   NO_SPACE           ; if so, don't display space
E2 0A           LOOP NO_SPACE           ; if BpSC not zero, don't display space 
4B              DEC  BX                 ; decrement Space Counter (SC) 
75 03           JNZ  DO_SPACE           ; if SC is zero, restart it and increment BpS 
B3 05           MOV  BL, 5              ; reset SC to 5 
46              INC  SI                 ; increment BpS 
            DO_SPACE: 
8B CE           MOV  CX, SI             ; reset Beeps per Space Counter (BpSC) 
CD 29           INT  29H                ; display space 
            NO_SPACE: 
4D              DEC  BP                 ; decrement Beeps Counter (BP) 
75 EA           JNZ  BEEP_LOOP 
            EXIT: 
C3              RET                     ; return to DOS 
        BEEP    DB   'beep$'
```
Someone in the comments described this challenge as "evil". I wouldn't go that far... but definitely lacking empathy.
Arbitrary modulos can be pesky in x86 when registers are tight. This is the inelegant counter/countdown approach (seemed only appropriate for an alarm clock challenge), basically just jockeying these three counters:
* `SI` = *Beeps per Space (`BpS`)*: Start at `1`. Increment every `5` spaces displayed. Once
`5` is reached, no more spaces are displayed.
* `BX` = *Space counter (`SC`)*: Start at `5`. Decrement every space displayed.
At `0`, increment `BpS` and reset to `5`.
* `CX` = *Beeps per Space Counter (`BpSC`)*: Start at `1`. Decrement every `'beep'` displayed. At `0`, display a space and reset
to current `BpS`.
A standalone PC DOS executable, input is via command line.
[![enter image description here](https://i.stack.imgur.com/133lH.png)](https://i.stack.imgur.com/133lH.png)
**Props: -1 byte thx to [@gastropner](https://codegolf.stackexchange.com/users/75886/gastropner)!**
[Answer]
# [Python 3](https://docs.python.org/3/), ~~134~~ ~~124~~ 118 bytes
```
def f(n):
 b=[*'beep']*n
 for i in b'\4\t\16\23\30!*3<ER_ly\x86\x97\xa8\xb9\xca\xdb':b.insert(i,' ')
 return''.join(b)
```
[Try it online!](https://tio.run/##PY5BDoIwFAX3PcXTTSmpRq0CGnHnBdz6jaFaYo35kIpJOT3ixjnAzLR992jYDMPd1agTVjsBW55TaZ1r5SVlgboJ8PAMK2lNHS0zWhkyi0lq9sfT9dVTLDKK25xiVVC0W4q3iuLdyp2de3670CVeS0glEFz3CSzl/Nl4TqwaGCXORmOhsdTINQqNzUYjyy9C/Ms8Xo20wfPPhensMNXjrldq@AI "Python 3 – Try It Online")
Explanation: Simply works by inserting a blank space at the required indices of the string.
*Thanks to pxeger for -6 bytes*
[Answer]
# [R](https://www.r-project.org/), 95 bytes
```
substr(s<-Reduce(paste,strrep("beep",c(rep(1:4,e=5),25))),1,c(el(gregexpr("b",s))[scan()]+3,0))
```
[Try it online!](https://tio.run/##FcqxCoNAEEXRf9lqHhlBk9iI/oStpFg3D5sgy4xC/n5dy3u4Voqfqx8mPjYzv2ei5OgHtZoxS1jJHDTJHd3wVk499NkD0K4yf7IZN/6z1TeoA4unuAs@j5e2QGnLBQ "R – Try It Online")
Thanks to @Dingus for pointing out a bug which made my code longer (and also wrong). Thanks to madlaina for suggesting a better regex.
Outgolfed handily by [Dominic van Essen](https://codegolf.stackexchange.com/a/209939/67312).
```
nreps <- c(rep(1:4,e=5),	# repeat the beeps 1,2,3,4 each 5 times
		25)		# and 25 times
beep <- strrep("beep",nreps)	# build a list of the repeated "beep"s
s <- Reduce(paste,beep)		# combine into one string, separated by spaces
i <- el(gregexpr("b",s))	# find the start index of each occurrence of a "beep"
e <- i[scan()]+3		# find the end index: the starting point of the n'th beep + 3
substr(s,1,c(e,0))		# and substring into s from 1 to e (or 0 if e is empty)
```
[Answer]
# [R](https://www.r-project.org/), ~~89~~ ~~87~~ ~~73~~ 69 bytes
*Edit: -20 (yes, 20) bytes thanks to Giuseppe*
```
x=scan();cat(strrep("beep",c(b<-(a=5:24%/%5)[cumsum(a)<x],x-sum(b))))
```
[Try it online!](https://tio.run/##K/r/v8K2ODkxT0PTOjmxRKO4pKgotUBDKSk1tUBJJ1kjyUZXI9HW1MrIRFVf1VQzOrk0t7g0VyNR06YiVqdCF8RO0gSC/@am/wE "R – Try It Online")
The guts of this are stolen from [Giuseppe's R answer](https://codegolf.stackexchange.com/questions/209921/print-my-clocks-alarm-sound/209930#209930), so please upvote that one... Edit: especially after he's now massively golfed-down this one!
However, I wanted to see whether a simpler, non-regex approach of constructing the correct number of 'beep'-repetitions (instead of making a very long one and then cutting it down) could be shorter.
So far it is...
[Answer]
# [Python 2](https://docs.python.org/2/), 59 bytes
```
f=lambda n:n*"?"and f(n-1)+"beep "[:4|0x444444924aabe>>n&1]
```
[Try it online!](https://tio.run/##HcxLCsIwFEbhuau4XKi0GsHGNGLAupDSQUKTWtC/IXag4N7j48y/E1/LdYbMOZxv9u4GSzDY8IUtBgoldnW1Zed9JO6Meu@f6t9JKmudb1us6z6HORFoAiWL0ZeHr@maRmgt9LE3K4ppwkJcyAcXEL9tlT8 "Python 2 – Try It Online")
Uses a hardcoded lookup table to decide whether to put a space after each beep. I attempted to make formulas instead but didn't find something shorter.
[Answer]
# [dotcomma](https://github.com/RedwolfPrograms/dotcomma) (old), 96577 bytes
Dotcomma is a language I created. I don't think I have any documentation or interpreter to link to yet, so it's not really competing at the moment. Takes input based on the number of inputs. Because it's so long, and very repetitive, here's the two blocks it's made up of:
**For every `beep` without a space:**
```
[[,.],[[[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,][[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,][[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,][[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,]]]
```
**For every `beep` with a space:**
```
[[,.],[[[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,][[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,][[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,][[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,][[.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.][.].,]]]
```
There's probably a way to golf down those constants. Anyway, I'll post an explanation when I have time.
**Update:** Dotcomma now has documentation and an interpreter. Because I added so many important new features since I posted this, it's practically a different language. If anyone else wants to post a different dotcomma answer that uses the full extent of the language's features, go ahead!
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~16~~ 15 bytes
```
wmΣC:Ṙ5ḣ4¹R¨⁸ep
```
[Try it online!](https://tio.run/##ASMA3P9odXNr//93bc6jQzrhuZg14bijNMK5UsKo4oG4ZXD///81OA "Husk – Try It Online")
## Explanation
```
¨⁸ep    Compressed string literal "beep"
R       Repeat n times, n is input:
          ["beep","beep",..,"beep"]
C:Ṙ5ḣ4¹    Cut the above into pieces.
    ḣ4     Range to 4: [1,2,3,4]
  Ṙ5       Replicate 5 times:
             [1,1,1,1,1,2,2,2,2,2,..,4]
 :    ¹    Append n:
             [1,1,1,1,1,2,2,2,2,2,..,4,n]
C          Cut the beep list to these lengths:
             [["beep"],["beep"],..,[..,"beep","beep"]]
           C stops when it runs out of elements, possibly cutting the last list short.
           In this case it has to, since the beep list has length n.
mΣ    Concatenate each:
        ["beep","beep",..,"beepbeep...beep"]
w     Join by spaces, implicitly print.
```
[Answer]
# [Poetic](https://mcaweb.matc.edu/winslojr/vicom128/final/), 853 bytes
```
anything i did was futile
o,a clock i set definitely failed
i know i,at one A.M,crave a rest
i notice,o!the alarm!it beeps
it provides no break to get a dream
its six A.M
aaggh,i got up
should i get sleep at six A.M while in bed?nope,never
i need to snooze now,but couldnt
im tired
ill get cereal:a bowl,milk,flakes
o no,the milk spills
dammit,i shout,getting kleenex and old unclean napkins
next,the pouch of frosted flakes
finally,i make a toast
i look,o no!eight A.M
must i hustle,so i begin at ten?i needed to rush,i am tardy
so i change:i get a jacket,i get a shirt
aw hell,o no,found no pair o pants
ill clearly suffer in a pair o boxers
i see,o no!eleven A.M
its a shame,o,too late
really,ill wear a blouse
so now i hurry
o,here now
i sit
time flies
i see,o my!three P.M
now i earned a rest
i badly ne-ee-ee-ee-eeeded a nap
i topple,and then i do
```
[Try it online!](https://mcaweb.matc.edu/winslojr/vicom128/final/tio/index.html?RVPBrpwwDLzzFd572ltV6V2e@gGV@guGGEgJMUrMsvTnX8fstk9CgiST8XjGcDltTmWiRDFFOrjRuFvK0mlgGrIOC46aGEUZU0km@aSRAYhdoqXoQSmwkRahH19/hqHyXYipSjMAiloaJOjNZuxmrustGfUiW@vwsVW9pygNOOqr8EKmNKEYU8RyBaZRSw@n7pinaQ6JJjXat67NuucIcY5vGZQEHS8wHTMkUiqoFd@LbhKK3KW6JJHoZVpR/SOofIR@NxqcrUDzSpaqd5fzRT0IlOQ3pl6PHNaUlzBmXqR1isvBG/NNahtutC7yuiaDTNdnAQzm9i4QWORBXCIpZO9lyMKFCm9LKq3DmV1cm@7DTDrSWLUZpL6KwXzO@QTxijUMMuXL4qy6BJdykzTNdlm17s3gzIxXltAU371McAMOmZT3pwtPH@re3FVG31zj2V3oYeYyyVt6hfGbh0W8qeeyzalaxwfNkvNVO4y6ozPEuHGq5K9i7fLQ@6wYmraPo1SPhP@Ben1IBQrzJa8WMlIqVw8evZfiFWfBVCmzSedhuA1gPkAMSJ91b@K6r2lE17WeGN8ZwfmW8yfrLK0CM5N8FlxPzGUVoV@o97wMygJf/g9wzxHai3yRz@dyjj06AEy3DR57roiv@H@kH9@/feDiXw)
This was a tough program to write. I wrote the poem about an alarm that wakes me up way too early.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~17~~ 16 [bytes](https://github.com/DennisMitchell/jelly)
```
4Rx5Ä‘œṖȧ€“&?»$K
```
A monadic Link accepting an integer which yields a list of characters.
**[Try it online!](https://tio.run/##AScA2P9qZWxsef//NFJ4NcOE4oCYxZPhuZbIp@KCrOKAnCY/wrskS////zg "Jelly – Try It Online")**
### How?
```
4Rx5Ä‘œṖȧ€“&?»$K - Link: integer, n     e.g. 8
4                - four                      4
 R               - range                     [1,2,3,4]
   5             - five                      5
  x              - times                     [1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4]
    Ä            - accumulate                [1,2,3,4,5,7,9,11,13,15,18,21,24,27,30,34,38,42,46,50]
     ‘           - increment                 [2,3,4,5,6,8,10,12,14,16,19,22,25,28,31,35,39,43,47,51]
              $  - last two links as a monad - i.e. f(n):
          “&?»   -   compressed string       "beep"
        ȧ€       -   (n) AND each ("beep")   ["beep","beep","beep","beep","beep","beep","beep","beep"]
      œṖ         - split before indices      [["beep"],["beep"],["beep"],["beep"],["beep"],["beep","beep"],["beep"]]
               K - join with spaces          "beep beep beep beep beep beepbeep beep"
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~22~~ ~~21~~ ~~20~~ 19 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
F’¼®b’4L5и{¦.¥NåúRJ
```
-1 byte by porting the approach used in multiple other answers.
[Try it online](https://tio.run/##yy9OTMpM/f/f7VHDzEN7Dq1LAtImPqYXdlQfWqZ3aKnf4aWHdwV5/f9vAQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKS/eGtlf/dHjXMPLTn0LokIG3iY3phR/WhZXqHlvodXnp4V5DX/1qd/9HGOgY6hjrmOhY6pqY6ZuY65qaxAA).
---
Original approach:
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), ~~22~~ 21 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
'¬ž4L₂¸«×5иé»Z¡I£'p«J
```
Output is joined by newlines. If this has to be spaces instead, 1 byte has to be added by replacing the `»` with `ðý`.
[Try it online](https://tio.run/##AS0A0v8wNWFiMWX//yfCrMW@NEzigoLCuMKrw5c10LjDqcK7WsKhScKjJ3DCq0r//zg) or [verify all test cases](https://tio.run/##MzBNTDJM/V@m5JlXUFpipaBkX6nDpeRfWgLh6fxXP7Tm6D4Tn0dNTYd2HFp9eLrphR2HVx7aHXVoYeWhxeoFh1Z7/dc5tM3@f7SxjoGOoY65joWOqamOmbmOuWksAA).
I wanted to use the legacy version of 05AB1E, since the maximum builtin `Z` works on strings (getting the character with the largest codepoint), which isn't the case in the new version of 05AB1E. This would have saved a byte over `'r`. Unfortunately, the legacy version lacks the append\_to\_list builtin `ª`, so we'll have to use `¸«` instead.
**So here is a regular [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands) version as well with the same ~~22~~ 21 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage):**
```
'¬ž4L₂ª×5иé»'r¡I£'p«J
```
[Try it online](https://tio.run/##ASwA0/9vc2FiaWX//yfCrMW@NEzigoLCqsOXNdC4w6nCuydywqFJwqMncMKrSv//OA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX6nDpeRfWgLh6fxXP7Tm6D4Tn0dNTYdWHZ5uemHH4ZWHdqsXHVpYeWixesGh1V7/dQ5ts/8fbaxjoGOoY65joWNqqmNmrmNuGgsA).
**Explanation:**
```
F                       # Loop `N` in the range [0, (implicit) input-integer):
 ’¼®b’                  #  Push dictionary string "peeb"
 4L                     #  Push list [1,2,3,4]
   5и                   #  Repeat it 5 times: [1,2,3,4,1,2,3,4,...]
     {                  #  Sort it: [1,1,1,1,1,2,2,2,2,2,...]
      ¦                 #  Remove the first value
       .¥               #  Undelta this list (with implicit leading 0):
                        #   [0,1,2,3,4,6,8,10,12,14,17,20,23,26,29,33,37,41,45,49]
         Nå             #  Check if `N` is in this list (1 if truthy; 0 if falsey)
           ú            #  Pad "peeb" with that many leading spaces
            R           #  Reverse it to "beep" or "beep "
             J          #  Join all strings on the stack together
                        # (after the loop, the result is output implicitly)
'¬ž                    '# Push dictionary string "beer"
   4L                   # Push a list [1,2,3,4]
     ₂                  # Push 26
      ª                 # New version: Append it as trailing item to the list
      ¸«                # Legacy version: Wrap into a list; merge the lists together
                        #  [1,2,3,4,26]
        ×               # Repeat each string that many times:
                        #  ["beer","beerbeer","beerbeerbeer","beerbeerbeerbeer",...]
         5и             # Repeat this list five times
           é            # Sort it based on length
            »           # Join all strings in the list by newlines
             'r        '# New version: Push "r"
             Z          # Legacy version: Push the maximum character (without popping),
                        # which is "r"
               ¡        # Split the string on "r"
                I£      # Leave the first input amount of substrings
                  'p«  '# Append a "p" to each string in the list
                     J  # And join it all together again
                        # (after which the result is output implicitly)
```
[See this 05AB1E tip of mine (section *How to use the dictionary?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `’¼®b’` is `"peeb"` and `'¬ž` is `"beer"`.
[Answer]
# [Io](http://iolanguage.org/), ~~81~~ ~~78~~ 75 bytes
Shamelessly ported from Arnauld's answer.
```
f :=method(i,if(i>0,f(i-1).."beep".." "repeated(1200959982447294>>i&1),""))
```
[Try it online!](https://tio.run/##DYxBCsMgEADveYV4KC5sg9qkxkL9S9qsZCGJYv2/dQ4zt@HUWhSv90l1T5ti5Kg4aOy@GxhH@SHKslfIQpnWSpsyVms/e7/YaXLWTyHwzQBKCdAO/lWl0eADHS44z/h0IGIqtH73vh9Ep89B5MJXPa4B2h8 "Io – Try It Online")
# [Io](http://iolanguage.org/), ~~152~~ 113 bytes
Port of Manish Kundu's answer.
```
method(x,O :=("beep"repeated(x)asList);"	!*3<ER_ly†—¨¹ÊÛ"foreach(i,if(i<x*4,O atInsert(i," ")));O join)
```
[Try it online!](https://tio.run/##y8z/n6ZgZasQ8z83tSQjP0WjQscfyNdQSkpNLVAqSi1ITSxJBYpqJhb7ZBaXaForsXDyCUsoahnbuAbF51Qeajs0/dCKQzsPdx2erZSWX5SamJyhkamTmaaRaVOhZQI0LLHEM684tagEKKqkoKSpqWntr5CVn5mn@T8HaKCGgY6hjrGOuY6Fjqmpjpm5pgLCEC4FIAAapKlQUJSZV5KTx6X5HwA "Io – Try It Online")
## Explanation
```
method(x,    // Input x
    O :=("beep"repeated(x)asList)            // "beep" repeated x times
    "	!*3<ER_ly†—"foreach(i,           // For every codepoint in this string:
        if(i<x*4,                            //     If doing this doesn't cause an error:
             O atInsert(i," ")));            //          Insert at this position
    O join)                                  // Join O without a separator
```
[Answer]
# [J](http://jsoftware.com/), 50 46 bytes
```
;@({.<@,&' '@;/.[$<@'beep')&((##\)25,~1+5#i.4)
```
[Try it online!](https://tio.run/##y/pvqWhlbK4QrWCgYGhgYACkjIyMuJT01NMUbK0U1BV0gCJWQKyrp@Ac5OP239pBo1rPxkFHTV1B3cFaXy9axcZBPSk1tUBdU01DQ1k5RtPIVKfOUNtUOVPPRPO/JhdXanJGvkKagiGMYQpjmMEY5jCGBYxhZABhqavD1Zj@BwA "J – Try It Online")
## how
`25,~1+5#i.4` produces:
```
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 25
```
`(##\)` pairs that with an integer list of the same length:
```
1 1 1 1 1 2 2 2 2  2  3  3  3  3  3  4  4  4  4  4 25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
```
and duplicates the bottom list according to the corresponding element of the top list:
```
1 2 3 4 5 6 6 7 7 8 8 9 9 10 10 11 11 11 12 12 12 13 13 13 14 14 14 15 15 15 16 16 16 16 17 17 17 17 18 18 18 18 19 19 19 19 20 20 20 20 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21
```
Call this our "key". We're going to use it to group our "beep"s together.
Our key becomes the right argument to `;@({.<@,&' '@;/.[$<@'beep')`.
`[$<@'beep'` first duplicates "beep" according to the input. Say, for an input of 8 we get:
```
┌────┬────┬────┬────┬────┬────┬────┬────┐
│beep│beep│beep│beep│beep│beep│beep│beep│
└────┴────┴────┴────┴────┴────┴────┴────┘
```
`{.` takes the first 8 elements of our key, creating a new key:
```
1 2 3 4 5 6 6 7
```
The key adverb `/.` applies the verb `<@,&' '@;` to each group defined by the new key. It unboxes, appends a space, and reboxes:
```
┌─────┬─────┬─────┬─────┬─────┬─────────┬─────┐
│beep │beep │beep │beep │beep │beepbeep │beep │
└─────┴─────┴─────┴─────┴─────┴─────────┴─────┘
```
`;@` unboxes again, giving the result:
```
beep beep beep beep beep beepbeep beep
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~108 120 118~~ 110 bytes
*+12 because I forgot to include the import statement which I had to put in the TIO header, not body*
*-2 by replacing \x00 with \0 - thanks to @ovs*
*-8 by filtering instead of replacing, and switching from `.` to `!`*
```
import zlib;lambda x:filter(33 .__ne__,zlib.decompress(b'x\x9cKJM-PH\xc2A(\x92\xc7\xa26\x97nb4!\0hm{7')[:x*5])
```
[Try it online!](https://tio.run/##HY3RCsIgGIVfZV3tN2qEa0nrqrsogu4zZG6OCdOJGrh6eHOdq@@Dwzlm9sOkyyiVmazPPqPkJ2Ol9sBnLxxAHBvFuyYLdS9HLyyUZVYwpgVjm6VddKKdlLHCOeB5oOHY3q737eNCQ4vPkBwnIjQ0@JCEaL5f0d2gviRHzzqsqxeKCJZDqc3bA0r5b3YicazIDw "Python 3 – Try It Online")
### How It Works
Sorry. I couldn't be bothered to come up with a clever algorithm.
`zlib` compressed string: `beep beep beep beep beep beep!beep beep!beep beep!beep beep!beep beep!beep beep!beep!beep beep!beep!beep beep!beep!beep beep!beep!beep beep!beep!beep beep!beep!beep!beep beep!beep!beep!beep beep!beep!beep!beep beep!beep!beep!beep beep!beep!beep!beep beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep!beep`
which is indexed into upto `n*5`th character, and then we filter for the bytes which don't equal 33 (exclamation mark). I chose `!` using a brute-force to find the the shortest compressed output from `zlib`.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 188 bytes
```
If[#==0,"",c=#;T@v_:=v~Table~5;w=Accumulate[z=Flatten@{T/@Range@4,25}];StringRiffle[""<>#&/@Join[1~Table~#&/@z[[;;Max@Position[w,m=Max@Select[w,#<=c&]]]],{Table[1,c~Mod~m]}]/. 1->"beep"]]&
```
[Try it online!](https://tio.run/##LY3Ra8IwGMT/FUmhT98W69Ypi5H4MthAcNq3EEbMvnaBJh1bqsPS/utZFe/luB/cndPhC50O1uhY8fhayoTzKRAChiesEMePZ34cCn2occjZia@NaV1b64DyzF9GD@hFV1Cx075C8QizvFdsH36sr3a2LGuUhCxXSUrFW2O9zG5bF3CWkrGN/hPb5tcG23h5AscvYI81mjDGZMlNqkZBd@3JDMywaT4Hp3pF7yfZ3YocEL@JUml8by0GuR2vAxUVFZPuAaaQwRwWkOfwNO9VjP8 "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3) , 164 Bytes
[Try it online](https://tio.run/##VY2xCoMwFAB3vyI8EF7MoxCrHULtj4QMiokNmFQaEfv1qQ4dut1yd8tnfb7iNceubvPUzX0Yxp4l2imoxLxj4RGZnZNlEyYBg7ULVLsABoS6bkkaoXeBoWzukptKNlxjEJKX8mbohGLrJgQgSQe73yCQV5tW3vwt3KnSdnE@jggDkD8CvFjePq7o8EzwnL8)
This is my recursive approach. Somehow it's worse than I imagined it in my head.
Explanation:
*n* is the input number
The *g* function generates the beep sequence, where *x* controls the numbers of "beep"s . Every 4th call *x* is incremented by 1, and with the 16th call it's set to 25. In the next call it's reset to 1 . *g* generates *n* groups of "beep"s
the string is stored in *v*
*f* cuts *v* to the corrext number by searching for the next "b" in *v* until *n* is reached.
```
g=lambda s,x,m:s if m>n else g(s+"beep"*x+" ",([25,1]+[x+(m%4<1)]*14)[(m+1)%16],m+1)
v=g("",1,1)
f=lambda m,i:v[:i] if m>n else f(m+1,v.find("b",i+1))
print(f(1,1))
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 32 bytes
```
∊' ',⍨¨(⎕↑×∊↑⍨¨25,⍨5/⍳4)⊂⊂'beep'
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKNdITEnsSgXyOpSV1DXedS74tAKjUd9Ux@1TTw8HSgIpMFiRqYgOVP9R72bTTQfdTUBkXpSamqBOsiM/wpgADaJy5hLXVdXV50LWcwAi5ghFjFzLGIWWMRMTbEImpn/BwA "APL (Dyalog Unicode) – Try It Online")
With significant golfing input from ngn.
### Explanation
The code inside the parens builds a boolean array describing the grouping pattern, which we'll come back to below; quad (`⎕`) prompts for the quantity of beeps and the pattern is cut to that number. To the right of the parens the word `'beep'` is enclosed (monadic `⊂`) to make it a single thing (instead of an array of 4 characters), and that is partition-enclosed (dyadic `⊂`) by the pattern which groups the beep and implicitly repeats it to match the cut pattern length. To the left of the parens, the `beep`s get one space (`' '`) appended (`,⍨`) to each (`¨`) group of them, then get flattened (`∊`) into the result string.
Building the group pattern follows this progression:
```
      5/⍳4           ⍝ five-replicate the first four numbers
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4
      25,⍨5/⍳4       ⍝ append 25 for the long run
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 25
      ↑⍨¨25,⍨5/⍳4    ⍝ turn each (¨) of the numbers into 
                     ⍝ a group that long, padded with zeros.
                     ⍝ using take selfie (↑⍨).
                     ⍝ e.g. Take first 3 items out of "3", get 3 0 0.
┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→──┐ ┌→──┐ ┌→──┐ ┌→──┐ ┌→──┐ ┌→────┐ ┌→────┐ ┌→────┐ ┌→────┐ ┌→────┐ ┌→──────┐ ┌→──────┐ ┌→──────┐ ┌→──────┐ ┌→──────┐ ┌→─────────────────────────────────────────────────┐
│1│ │1│ │1│ │1│ │1│ │2 0│ │2 0│ │2 0│ │2 0│ │2 0│ │3 0 0│ │3 0 0│ │3 0 0│ │3 0 0│ │3 0 0│ │4 0 0 0│ │4 0 0 0│ │4 0 0 0│ │4 0 0 0│ │4 0 0 0│ │25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0│
└~┘ └~┘ └~┘ └~┘ └~┘ └~──┘ └~──┘ └~──┘ └~──┘ └~──┘ └~────┘ └~────┘ └~────┘ └~────┘ └~────┘ └~──────┘ └~──────┘ └~──────┘ └~──────┘ └~──────┘ └~─────────────────────────────────────────────────┘
      ∊↑⍨¨25,⍨5/⍳4    ⍝ flatten (∊) the nesting
1 1 1 1 1 2 0 2 0 2 0 2 0 2 0 3 0 0 3 0 0 3 0 0 3 0 0 3 0 0 4 0 0 0 4 0 0 0 4 0 0 0 4 0 0 0 4 0 0 0 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
      ×∊↑⍨¨25,⍨5/⍳4    ⍝ use direction (×) to turn all non-zero into 1
                       ⍝ 1 marks the start of each group, 0 pads their length.
                       ⍝ A boolean group-array for the full beep pattern
1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
      20↑×∊↑⍨¨25,⍨5/⍳4    ⍝ take (↑) 20 beeps. (⎕ number beeps)
                          ⍝ This is how it cuts in the middle of a 
                          ⍝ run of beepbeepbeep, by cutting the pattern.
1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0
      (20↑×∊↑⍨¨25,⍨5/⍳4)⊂⊂'beep'    ⍝ p-enclose of 'beep' shows the grouping,
                                    ⍝ and the cutoff group at the end.
┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→──────────────┐ ┌→──────────────┐ ┌→──────────────┐ ┌→──────────────┐ ┌→──────────────┐ ┌→─────────────────────┐ ┌→──────────────┐
│ ┌→───┐ │ │ ┌→───┐ │ │ ┌→───┐ │ │ ┌→───┐ │ │ ┌→───┐ │ │ ┌→───┐ ┌→───┐ │ │ ┌→───┐ ┌→───┐ │ │ ┌→───┐ ┌→───┐ │ │ ┌→───┐ ┌→───┐ │ │ ┌→───┐ ┌→───┐ │ │ ┌→───┐ ┌→───┐ ┌→───┐ │ │ ┌→───┐ ┌→───┐ │
│ │beep│ │ │ │beep│ │ │ │beep│ │ │ │beep│ │ │ │beep│ │ │ │beep│ │beep│ │ │ │beep│ │beep│ │ │ │beep│ │beep│ │ │ │beep│ │beep│ │ │ │beep│ │beep│ │ │ │beep│ │beep│ │beep│ │ │ │beep│ │beep│ │
│ └────┘ │ │ └────┘ │ │ └────┘ │ │ └────┘ │ │ └────┘ │ │ └────┘ └────┘ │ │ └────┘ └────┘ │ │ └────┘ └────┘ │ │ └────┘ └────┘ │ │ └────┘ └────┘ │ │ └────┘ └────┘ └────┘ │ │ └────┘ └────┘ │
└∊───────┘ └∊───────┘ └∊───────┘ └∊───────┘ └∊───────┘ └∊──────────────┘ └∊──────────────┘ └∊──────────────┘ └∊──────────────┘ └∊──────────────┘ └∊─────────────────────┘ └∊──────────────┘
      ∊' ',⍨¨(20↑×∊↑⍨¨25,⍨5/⍳4)⊂⊂'beep'    ⍝ append one space in each group
                                           ⍝ and flatten.
beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeep
```
[Answer]
# [Rust](https://www.rust-lang.org/), 76 ~~127~~ bytes
```
|n|(0..n).fold("".into(),|a,i|a+"beep"+&" "[..0x222222492555F>>i.min(63)&1])
```
[Try it online!](https://tio.run/##Tc49C4MwEAbgWX9FmkEuaIPWxn7i6NapY@mgaCRQY9EESht/e2qFQm57uLv3btCjslyirhQSCPr4nmpGBdZIAzGlklDeP2rAmAqpeiCRKSNhyhBXTfPEYYARvlEavzZLbQ8bxliR54J2c16WkiC5E@uRkz/5/nzmF34ujqiQF61Aj@LdELTO0VUNQrY5dFohPreXT@qqXQGHlMzrf8QuEhc7F3sXjLnKlsHJfgE "Rust – Try It Online")
Shamelessly ported from [Arnauld's JS solution](https://codegolf.stackexchange.com/a/209934/97519)
The binary constant has a bit set wherever the "beep" should be followed by a space.
## Old solution
```
|n|[1,2,3,4,25].iter().fold(format!(""),|a,&i|a+&("beep".repeat(i)+" ").repeat(5)).rsplitn(176-n,'b').last().map(str::to_owned)
```
[Try it online!](https://tio.run/##bY@xasMwEIbn@CkUDckdUUSd1Elxg8dspUPHUoqM5SCwJSGdCbTOs7tqIUPB293Hz3f/hSHS1FrWK2MB2Xe2IB0JptGO77nYib14FLviQxrSAVC2rmugdaFXtATOUYxKrMyoNivgtdaey6C9VgQGN5xxvK8FpjH6zpCF/HjYWrGu1yg7lW6h7JWHSKEsyX26q9UNTgt8zm5Zlpr99jmdS3a2LwPBEM2XRrat2Ksn4@zpjYKxl6qCfiDWptjfE019WUILe5SDvYakx@S704dZms/S4yx9mqVFMYsP/x23bPoB "Rust – Try It Online")
### Explanation:
We first construct the string `beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep...` with the last 25 successive `beep`s also being repeated 5 times. This string contains 175 `beep`s, so we trim from the right to and including the `176-n`th `b` and take the sub string left of there.
[Answer]
# APL+WIN, 50 bytes
Prompts for input of n:
```
(4×(p/m),¯1↑-(p←n≤0)/n←(+\m←(5/⍳4),25)-⎕)⍴¨⊂'beep'
```
[Try it online! Courtesy of Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcjzra0/5rmByerlGgn6upc2i94aO2iboaBUDJvEedSww09fOATA3tmFwQZar/qHeziaaOkammLtAMzUe9Ww6teNTVpJ6Umlqg/h9o2P80LmOuNC4DIDYEYnMgtgBiU1MgYWbOxQUA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 23 bytes
```
ＦＮ«beep¿＆⍘(XsB!,zOγＸ²ι→
```
[Try it online!](https://tio.run/##DcyxDoIwEADQGb7i7HRN6uKgiU52c1CJLq4FD7gEWtIWSDR@e@3@8pre@MaZIaXWecCLneZ4m8eaPEoJ37KoPNuIoiaahDyVBbeAmuPKgc72jdoEesZsOhT4CnqjPnehoJMKKrfmZaeAZa6ubiE8PrjrY25@Ke0PabsMfw "Charcoal – Try It Online") Link is to verbose version of code. Uses the popular bitmask approach. Explanation:
```
ＦＮ«
```
Loop the given number of times.
```
beep
```
Print a beep.
```
¿＆⍘(XsB!,zOγＸ²ι→
```
If the appropriate bit in the constant is set, then move right one character. The constant is probably the same as everyone else's but here I'm effectively encoding it using base 95.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 68 bytes
```
(0.."$args"|%{' '*((0x444444924AABE-shr$_)%2)*($_-lt52)})-join'beep'
```
[Try it online!](https://tio.run/##7VRtS8MwEP7eX3HU1CSjGbWuTgXFCf6O0m3nWoldTTI26frba8xeiuCHCvOTBnLc2/NwdyRXLdeodI5StuQZ7qBuWTQc@iRTC@1vg5oCHTAWbUbu3MSjyeTxSehckZQHMR8wkgppkpg3XLwsi5JOESvaNp73wLyQXQJA6HzQCcqt9wyy8h2MygpZlAtY54VBXWUzhEJDJqWta24JIkdAuVUvOi5nj7/j/iq65Oueya78T0CS9Af0VU5i/Jrj2PrV@C@2/tO7e4PJ/6hOMkoOWwig9uw3BVKuXqeoQiC4qXBmcG4XE0l3MYV6JY11nNt9tc90EZ@wfVDg2xHJbw9JIO4PaN9r2g8 "PowerShell – Try It Online")
The script:
1. generates an array of whitspace and empty strings
2. joins array elements with 'beep'
The script can add a trailing whitespace that is allowed by the author. See the test cases in the TIO link.
The Powershell works with 64 bitmasks only, so I had to add a condition `($_-lt52)`
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~72~~ \$\cdots\$ ~~66~~ 60 bytes
Saved 10 bytes thanks to the man himself [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)!!!
```
f(n){n&&printf(" beep"-~-(0x888889249557c>>n&n<55),f(n-1));}
```
[Try it online!](https://tio.run/##5ZPBCsIwDEDvfkUpOFqwsDq7Tie7@Re7aLeJB8MQD4LMX5@d2ApTysT1ZKAhTZvmkaSK7ZVq24oAvUIQ1KcDnCuC0a4sa8xujISXpJPlfLEUQqosgwDWQtCZDmGc0rRpdQg6bg9A6OQ6QVrMK1O2KPAMRTR9uCtiLHMhh82lLtW5LFY5RPqgS/tSObBfJQfcy/mECi1U6IIKfTJwy8BdDPxZGJ8o0qJIF4p861FP@eZMLGfi4kyGcHovqv4mhtaaH3GFGIo71Bhl483hu/Dxa5xj5zzH8v8K/@0arVFNewc "C (gcc) – Try It Online")
Recursively calls itself \$n\$ times evaluating a bitwise expression (where the \$1\$ bits of a hard coded integer indicate if a space is needed) to determine whether or not to prefix the current `beep` with a space. This is done by adding \$0\$ or \$1\$ to a string literal (`char*` pointer) to offset it by one or not.
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 20 bytes
```
4ɾƛS5*fvI;?Jf«⟇½⁰«*Ṅ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=4%C9%BE%C6%9BS5*fvI%3B%3FJf%C2%AB%E2%9F%87%C2%BD%E2%81%B0%C2%AB*%E1%B9%84&inputs=58&header=&footer=)
[Answer]
# [PowerShell 5.1](https://docs.microsoft.com/en-us/powershell/), 227 bytes
```
$n=10;function f($x){$r.Length-in$x};$c=0;$r="";$t=0;while($c-lt$n){$s=-1;switch($true){{f(0..24)}{$s=1}{f(25..69)}{$s=2}{f(70..134)}{$s=3}{f(135..219)}{$s=4}};$r+="beep";$t++;if($t-ne$s){$c++;continue};$r+=" ";$t=0;$c++};$r
```
Explanation: $n is the input number. I tried to write this without doing it via arrays because I felt like it would be cheating, as I had already read [this answer](https://codegolf.stackexchange.com/questions/209921/print-my-clocks-alarm-sound/209927#209927). I used the length of the string to determine how many "beeps" were needed before I placed a space. If the length of the string is between 0 and 24, 1 space. If the length of the string is between 25 and 69, 2 spaces. etc.
Here's the "cleaner" version
```
$n = 9
function bl ($x) {$beepString.Length -in $x}
$count = 0
$beepString = ""
$beepsThisTime = 0
while($count -lt $n)
{
    $neededBeepsBeforeSpace = -1
    switch($true)
    {
        {bl(0..24)}{$neededBeepsBeforeSpace = 1}
        {bl(25..69)}{$neededBeepsBeforeSpace = 2}
        {bl(70..134)}{$neededBeepsBeforeSpace = 3}
        {bl(135..219)}{$neededBeepsBeforeSpace = 4}
    }
    $beepString += "beep"
    $beepsThisTime++
    if($beepsThisTime -ne $neededBeepsBeforeSpace){$count++;continue}
    $beepString+=" "
    $beepsThisTime = 0
    $count++
}
$beepString
```
[Answer]
# [Lua](https://www.lua.org/), 105 bytes
```
function b(n)t={}for i=5,24 do t[(i-1)*(i-2)//10]=' 'end for i=1,n do io.write('beep'..(t[i]or''))end end
```
Ungolfed code and test program:
```
function b(n)
    t={}
    for i=5, 24 do
        t[(i-1)*(i-2)//10] = ' '
    end
    for i=1, n do
        io.write('beep' .. (t[i] or ''))
    end
end
for k, v in ipairs({ 3, 0, 1, 7, 8, 55, 67, 75 }) do
    io.write(v .. '\t') b(v) print()
end
```
Output:
```
3   beep beep beep 
0   
1   beep 
7   beep beep beep beep beep beepbeep 
8   beep beep beep beep beep beepbeep beep
55  beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeepbeep
67  beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeep
75  beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeep beepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeepbeep
```
[Try it online](https://tio.run/##PY4xDsIwEARreMV29qHDJECAJi8BigQc6QSyI@OEIuLtwRYSxa22mB3dc2jmuRvcLYp3aLWjWE@fzgdIXfF2j7tHPGtZl7RKuaXNpiyutYKy7o4fV7LLmHjzDhKtVq21vTJGx7NcfVCKKMPp5jx4MEaIg/SNhJeesGMUjJJxZJwYVcU4pHqs8KEkXi7@5hHGQF2iovTqSOiDuKhpmdVf)
Edit 1: Thank you for your suggestions :) It greatly helped to compress the sequence that was used.
Edit 2: 99 Bytes solution provided by Arnault, getting rid of the (-1) and using a partial and clever one's complement to decrease a number:
```
function b(n)t={}for i=4,23 do t[i*~-i//10]=' 'end for i=1,n do io.write('beep'..(t[i]or''))end end
```
[Try it online](https://tio.run/##PY5BDoIwFETXcorZtTXfAiLihpMoCxBIfjQtqQUXBK@OJSYuJpnFm5d5jvW69qO5e7YGjTTKl/PSWwcuT3TM0Fr4K@8/B47jNKlKAdGZFj8iJbMBbPXbse@kaLpuEFrLMKmsE0KpDQ5Zt8GDMIENeKjZveSMjJAQUkJBuBDynHAOtcixqCCOdn/zBK0hbl6ocHJSGBwbL1W0qb8)
[Answer]
## [Setanta](https://try-setanta.ie/), ~~146~~ ~~144~~ ~~140~~ ~~124~~ 123 bytes
*-16 bytes by using a cheaper check for the first beep.*  
*-1 byte by discovering that braces could be left out in one place.*
```
gniomh(n){s:=""le i idir(0,n){a:=(i&freamh@mata((i-1)//5*8+1)+1)//2d:=(i-5*(a*a-a)/2)%a ma!d&i<51 s+=" "s+="beep"}toradh s}
```
[Try it here!](https://try-setanta.ie/editor/EhEKBlNjcmlwdBCAgICglsiZCg)
[Answer]
# [Zsh](https://www.zsh.org/), 64 bytes
```
repeat $1 z+=beep.
repeat 4 repeat x+=5,5 z[t+=x]=\ 
<<<${z//./}
```
[Try it online!](https://tio.run/##qyrO@F@cWqKg66Zgbvq/KLUgNbFEQcVQoUrbNik1tUCPCypkogBlqFdo25rqmKorVEWXaNtWxNrGKHDZ2NioVFfp6@vp1/7/DwA "Zsh – Try It Online")
Because of a bug that's not fixed in the Zsh version available on TIO, the `x+=5,5` needs to be single-quoted for +2 bytes.
Works by constructing a string of `beep.`, replacing some `.`s with spaces, and then removing the `.`s. The differences in the indeces at which to remove the `.`s are `5, 5, 5, 5, 5, 10, 10, ... 15, 15, 20, 20, 20, 20, 20`, so we cumulatively sum these as we go.
* `repeat $1`: do this {input} times:
	+ `z+=beep.`: append `beep.` to the variable `$z` (which implicitly starts empty)
* `repeat 4`:
	+ `repeat x+=5,5`: do this 5 times, but also increment `$x` by `5` (it starts at `0` implicitly) before the loop starts:
		- `t+=x`: increment `$t` (the cumulative sum) by `$x` (again, `$t` starts at `0` implicitly)
		- `z[]=\` : set the `$t`th character (1-indexed) of `$z` to a space
* `${z//./}`: take `$z`, with dots `.` replaced by {empty string}
* `<<<`: print
[Answer]
# [dotcomma](https://github.com/Radvylf/dotcomma), ~~617~~ 569 bytes
```
[,].[[[,.][[[[[.][.][.][.].,][,.].,][,.].,][[,][[[,][,.].,][,][,].,].,][,][[[,.][.][.].,][.][.][.].,][,][[[,.][[[,.][[,]].,][],].,],].[,][.,][[.][.][.][.][.].,].[.[.[[[,.][[].[],].,][[,][[,][[[[,][[[,],]].,],]].,][],][.[.[,].][,][,]].][,][[,][[,][,][,]].,][.[.[,].]][[,.][[].[],].,],.[[[,][[,.]].,][.[.[,].][,]]],.[.[.[,].][,[.][.][.][.][.].,][,]][,],.][.[.[,].][,]][[[,.][[].[],].,][,.].,].[.[,].][,][,],.][,][.[.[,].]][,[,[,[,[,[,[,[,.]]]]]]]]].,].[[.[.[,].]][[,.][[].[],].,][.[[,],]][.[.[,].][,][,]][.[,]][,.][.[.[,].][,][,.]][.[[,][,.],.]].][.[.[,.].]][,.]],.[[,.]]
```
-48 bytes by rearranging the last counter loop and thereby avoiding duplicate code.
Phew, I need to rearrange my brain again... Bracket chaos ^^
This is first try with this language. It's quite fun. The changes made to the old version seem to be very effective when I can shrink the program size to less than 1% of the old version. Are there plans to put this language on tio.run? What about plumber? I think that's interesing, too.
Use the following snippet on your own risk (especially when changing the dotcomma code. I had several freezes because I unintetionally created endless loops)
```
<script src="https://combinatronics.com/Radvylf/dotcomma/master/interpreter.js"></script><script src="https://code.jquery.com/jquery-3.5.1.min.js"></script><script>$(document).ready(function () {$("#btnInterpret").click(function () {$("#txtResult").text(interpret($("#txtCode").val(), parseInt($("#txtInput").val()), $("#lstOutputAs").children("option:selected").val()));});});</script><style>.textBox {background-color: white;border: 1px solid black;font-family: Courier New, Courier, monospace;width: 100%;}</style>Code: <textarea id="txtCode" type="text" class="textBox" style="height: 200px">[,].[[[,.][[[[[.][.][.][.].,][,.].,][,.].,][[,][[[,][,.].,][,][,].,].,][,][[[,.][.][.].,][.][.][.].,][,][[[,.][[[,.][[,]].,][],].,],].[,][.,][[.][.][.][.][.].,].[.[.[[[,.][[].[],].,][[,][[,][[[[,][[[,],]].,],]].,][],][.[.[,].][,][,]].][,][[,][[,][,][,]].,][.[.[,].]][[,.][[].[],].,],.[[[,][[,.]].,][.[.[,].][,]]],.[.[.[,].][,[.][.][.][.][.].,][,]][,],.][.[.[,].][,]][[[,.][[].[],].,][,.].,].[.[,].][,][,],.][,][.[.[,].]][,[,[,[,[,[,[,[,.]]]]]]]]].,].[[.[.[,].]][[,.][[].[],].,][.[[,],]][.[.[,].][,][,]][.[,]][,.][.[.[,].][,][,.]][.[[,][,.],.]].][.[.[,.].]][,.]],.[[,.]]</textarea><br />Input: <textarea id="txtInput" type="text" class="textBox">25</textarea><br /><input id="btnInterpret" type="button" value="Run" />Output as: <select id="lstOutputAs"><option value="true">String</option><option value="">Number array</option></select><br />Result:<br /><div id="txtResult" class="textBox" style="overflow-wrap: break-word"></div>
```
**Code:**
(sorry for the missing interpunctuation. This way I was able to run the commented code directly in the interpreter)
```
[,].[                           if input > 0
  [[,.][                        save input on recursion stack
    [
      [                         ### Build ASCII values for "b" "e" "p" and space " "
        [[.][.][.][.].,]        4
      [,.].,]                   8
    [,.].,]                     16
  
    [[,]                        put 16 on recursion stack and save copy in queue
      [
        [[,][,.].,]             32
      [,][,].,]                 96 
    .,]                         112 ("p")
                                in queue: 32 96 112
    [,]                         roll left (queue: "@p ")
    [[[,.][.][.].,][.][.][.].,] "b" "e"
    [,]                         roll left (queue: " bep")
    [[[,.][                     save " " on recursion stack
      [[,.][[,]].,]             reverse letters ("peb")
      [],                       insert 0 (start of queue)
    ].,],]                      save two copies of 32 (one for space character and one for counting beeps)
                                
                                ### Build list of "beep"s in reverse - each separated by a null char
                                Since the maximum input is 75 the 25 consecutive beeps at the end
                                will be limited by the input - so I can safely put a few more
                                beeps into the list because I just have a 32 handy
                                sc: spaces counter
                                pc: pattern counter
                                bc: beep counter
                                target queue: 0 0 sc pc bc " peb" 
                                current queue: "peb" 0 bc(32) " "
                                I will refer to the two consecutive 0s at the start of the variable
                                section as "start of queue" or just "start"
                                pc: |           1           |                   2                       |
                                sc: | 1 |  2 |  3 |  4 |  5 |    1   |    2   |    3   |    4   |    5  |
                                bc: | 1 |  1 |  1 |  1 |  1 |  1 | 2 |  1 | 2 |  1 | 2 |  1 | 2 | 1 | 2 |
                                    beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep 
    .[,]                        roll to start  
    [.,]                        insert 1 for spaces counter (since I append new beeps to the start of the
                                queue we are only one space away from the next pattern)
    [[.][.][.][.][.].,]         insert 5 for pattern counter
                                queue: pc(5) bc(32) " bep" 0 sc(1)
    .[                          while pattern counter > 0 ### Attention: current position is beep counter!
      .[                        while spaces counter > 0 ### Attention: current position is beep counter!
        .[                      while beep counter > 0
          [[,.][[].[],].,]      save beep counter -1 on queue (also hold it in recursion stack)
          [                     # put a copy of "beep" on the queue
            [,]                 roll over " "
            [[,][[              put "p" on recursion stack
              [[,][[            put "e" on recursion stack
                [,]             put "b" on recursion stack
                ,]]             put "b" on queue
              .,],]]            put "ee" on queue
            .,]                 put "p" on queue
            [],                 put 0 on queue
          ]
          [
            .[.[,].]            roll to start (roll until two consecutive 0s are found)
            [,][,]              go to beep counter
          ]
        .]                      return value for loop (end of beep counter loop)
                                # insert space
        [,]                     roll over beep counter
        [[,][[,][,][,]].,]      copy and insert space
                                # if spaces counter - 1 > 0: copy pattern counter to beep count
                                (the pattern counter contains the number of consecutive beeps
                                that should be separated by a space)
        [.[.[,].]]              roll to spaces counter
        [[,.][[].[],].,]        decrement spaces counter
        ,.[                     if spaces counter > 0
          [[,][[,.]].,]         replace beep counter with copy of pattern counter
          [.[.[,].][,]]         roll to pattern counter (if the spaces loop repeats we need to be at
                                the beep counter; I will read the next value to determine if the loop
                                should repeat; Thats's why I stop one value before beep counter)
        ],.[                    else                    
          .[.[,].]              roll to spaces count
          [,[.][.][.][.][.].,]  set it 5 for next round
          [,]                   roll to beep count
        ]
        [,],.                   get return value for loop (pattern counter for repeating 
                                or beep counter(0) for stopping)
      ]                         end of spaces loop
      [.[.[,].][,]]             roll to pattern counter
      [
        [[,.][[].[],].,]        decrement pattern counter
        [,.].,                  set new beep counter = pattern counter
      ]
      .[.[,].][,]               roll to pattern counter
      [,],.                     repeat if > 0
    ]                           end of pattern loop
    [,][.[.[,].]]               roll to start
    [,[,[,[,[,[,[,[,.]]]]]]]]   delete variables constants and excess space in front of first beep
  ].,]                          put input back into queue
                                ### Count beeps
                                The idea is to delete all 0s between the beeps until we match the input
                                then deleting everything behind it
                                I thought it would be easy to delete single 0s - What I didn't consider was
                                that I can end a loop only after a 0 has been processed so I needed a trick
                                What I do is: duplicate every character until I reach a 0 (which will also
                                be duplicated)
                                Then find the first 0 (reassigning it to the end of the queue) and delete
                                the second 0
                                After that I can delete the duplicated characters including the 0
  .[                            while input counter > 0
    [.[.[,].]]                  roll to start
    [[,.][[].[],].,]            decrement input counter
    [.[[,],]]                   duplicate until first 0
    [.[.[,].][,][,]]            roll to start + 2
    [.[,]]                      roll to first 0
    [,.]                        delete second 0
    [.[.[,].][,][,.]]           roll to start + 2 (deleting the second character)
    [.[[,][,.],.]]              delete every 2nd character until 0 found
  .]                            end of loop                     end of loop
  [.[.[,.].]]                   delete everything up to start
  [,.]                          delete input counter
],.[                            else (if input is 0)
  [,.]                          delete input and output nothing
]
```
[Answer]
# [Haskell](https://www.haskell.org/), 58 bytes
```
f n=do i<-[1..n];[' '|odd$div 0x888889249557c$2^i]++"beep"
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00hzzYlXyHTRjfaUE8vL9Y6Wl1BvSY/JUUlJbNMwaDCAgQsjUwsTU3Nk1WM4jJjtbWVklJTC5T@5yZm5inYKqTkcykoFJSWBJcU@eQpqCikKRijCxigCxiiC5ijC1igC5iaoouYmf8HAA "Haskell – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), 54 bytes
```
$_=" beep"x$_;s/ /0x444444924aabe>>$x&$x++<51?$&:""/ge
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZJISk1tUCpQiXeulhfQd@gwgQMLI1MEhOTUu3sVCrUVCq0tW1MDe1V1KyUlPTTU///NzP/l19QkpmfV/xftyAHAA "Perl 5 – Try It Online")
Ungolfed a bit:
```
$_=" beep"x$_;           # create string of space+beep the input number of times
s/ /                     # remove spaces unless it's space number
0x444444924aabe          # 1 2 3 4 5 7 9 11 13 15 18 21 24 27 30
                         # 34 38 42 46 or 50 (counting from zero)
                         # 0x444444924aabe in binary have 1's on
                         # those positions
>>$x                     # keep space if 1-bit and space number <= 50
&$x++<51?$&:""/ge        # remove space if not
```
]