15
\$\begingroup\$

Given a positive integer n, output the "FizzFizzFizzBuzz" sequence for that number: print the decimal representations of the numbers 1 through n (inclusive on both ends), separated by newlines, however for each number in the sequence:

  • If the number is divisible by both 3 and 5, instead of the number output Fizz the number of times it can divide by 3 without leaving a remainder, then Buzz the number of times it can divide by 5 without leaving a remainder. For example, 45 and 90 output FizzFizzBuzz, 75 outputs FizzBuzzBuzz, 135 outputs FizzFizzFizzBuzz, and 225 outputs FizzFizzBuzzBuzz.
  • Else if the number is divisible by 3, instead of the number output Fizz the number of times it can divide by 3 without leaving a remainder. For example, 9 and 18 output FizzFizz, and 27 and 54 output FizzFizzFizz.
  • Else if the number is divisible by 5, instead of the number output Buzz the number of times it can divide by 5 without leaving a remainder. For example, 25 outputs BuzzBuzz, 35 outputs Buzz, and 125 and 500 output BuzzBuzzBuzz.

Example to 200:

1
2
Fizz
4
Buzz
Fizz
7
8
FizzFizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
FizzFizz
19
Buzz
Fizz
22
23
Fizz
BuzzBuzz
26
FizzFizzFizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
FizzFizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzFizzBuzz
46
47
Fizz
49
BuzzBuzz
Fizz
52
53
FizzFizzFizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
FizzFizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
FizzFizz
73
74
FizzBuzzBuzz
76
77
Fizz
79
Buzz
FizzFizzFizzFizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzFizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
FizzFizz
BuzzBuzz
101
Fizz
103
104
FizzBuzz
106
107
FizzFizzFizz
109
Buzz
Fizz
112
113
Fizz
Buzz
116
FizzFizz
118
119
FizzBuzz
121
122
Fizz
124
BuzzBuzzBuzz
FizzFizz
127
128
Fizz
Buzz
131
Fizz
133
134
FizzFizzFizzBuzz
136
137
Fizz
139
Buzz
Fizz
142
143
FizzFizz
Buzz
146
Fizz
148
149
FizzBuzzBuzz
151
152
FizzFizz
154
Buzz
Fizz
157
158
Fizz
Buzz
161
FizzFizzFizzFizz
163
164
FizzBuzz
166
167
Fizz
169
Buzz
FizzFizz
172
173
Fizz
BuzzBuzz
176
Fizz
178
179
FizzFizzBuzz
181
182
Fizz
184
Buzz
Fizz
187
188
FizzFizzFizz
Buzz
191
Fizz
193
194
FizzBuzz
196
197
FizzFizz
199
BuzzBuzz

This is , so fewest bytes wins!

\$\endgroup\$
6
  • 5
    \$\begingroup\$ May we instead just take N and output the Nth line? \$\endgroup\$
    – noodle man
    Apr 10 at 1:17
  • \$\begingroup\$ Did you mean 225? \$\endgroup\$
    – Neil
    Apr 10 at 7:37
  • 1
    \$\begingroup\$ @noodleman No, you can't. \$\endgroup\$ Apr 10 at 9:33
  • 6
    \$\begingroup\$ Why three rules? That spec doesn't look golfed. \$\endgroup\$
    – no comment
    Apr 10 at 17:22
  • \$\begingroup\$ RIght now, all of the examples given in the spec have the special property that 3 and/or 5 are the only primes dividing the number. It would remove a potential confusion to change some of those examples to numbers like 18 and 55 and 90. \$\endgroup\$ Apr 12 at 0:24

24 Answers 24

9
\$\begingroup\$

Vyxal j, 74 bitsv2, 9.25 bytes

ƛ35fǑkF½*∑∴

Try it Online!

Bitstring:

00000111010011110100011111010010001101011001000110010010101010001001010100

The FizzBuzz formula strikes once again.

Explained

ƛ35fǑkF½*∑∴­⁡​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏‏​⁡⁠⁡‌­
ƛ            # ‎⁡To each number n in the range [1, input]:
 35fǑ        # ‎⁢  How many times do 3 and 5 cleanly divide n? Call this X
     kF½*∑∴  # ‎⁣  standard vyxal fizzbuzz
     kF½     # ‎⁤    ["Fizz", "Buzz"]
        *    # ‎⁢⁡     Repeated by each number in X, vectorised by zipping and reduction
         ∑∴  # ‎⁢⁢      Sum that, and get the biggest of n and that
💎

Created with the help of Luminespire.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ It needs the flags "j=" to give the correct output, shouldn't that count in the length? \$\endgroup\$ Apr 11 at 14:59
  • \$\begingroup\$ @Nowhereman by site consensus, flags do not count in the score \$\endgroup\$
    – lyxal
    Apr 11 at 22:25
  • \$\begingroup\$ codegolf.meta.stackexchange.com/q/14337/78850 \$\endgroup\$
    – lyxal
    Apr 11 at 22:30
  • \$\begingroup\$ What is the "💎" at the end of the explanation? And - sorry, but after reading the linked documentation and related Meta Q&A, and having intimate familiarity with compression algorithms generally, I still don't understand* the encoding scheme at all. What character set is used, and how does it represent the 2-bit remainder? If the code has been bit-packed and compressed, how can it be "explained" in a way that shows each part with a specific subsequence of characters? \$\endgroup\$ Apr 12 at 12:44
  • \$\begingroup\$ @KarlKnechtel the 💎 is to indicate that the explanation was generated using the Luminespire tool. The explanation uses the unpacked/uncompressed version of the program. \$\endgroup\$
    – lyxal
    Apr 12 at 12:46
7
\$\begingroup\$

JavaScript, 81 78 74 bytes

-4 bytes thanks to myself...
-3 bytes thanks to Arnauld.

f=n=>n&&f(n-1)+(g=s=>h=d=>n%d?'':s+h(d,n/=d),g`Fizz`(3)+g`Buzz`(5)||n)+`
`

Attempt This Online!

\$\endgroup\$
4
  • \$\begingroup\$ @Arnauld Thank you! I honestly don't see why the reassignment of n doesn't break in the second call to g \$\endgroup\$ Apr 10 at 23:12
  • \$\begingroup\$ Since \$3\$ and \$5\$ are both prime (and a fortiori co-prime numbers), you can safely divide \$n\$ by one and then the other. \$\endgroup\$
    – Arnauld
    Apr 10 at 23:19
  • \$\begingroup\$ Nice spot, by similar logic it's not necessary to reassign n \$\endgroup\$ Apr 10 at 23:24
  • \$\begingroup\$ Indeed! If \$n\$ has been modified, then we have at least one fizz or one buzz and don't need the original value anymore. \$\endgroup\$
    – Arnauld
    Apr 11 at 6:25
7
\$\begingroup\$

Python 3, 94 bytes

f=lambda n,d=0:d>1>n%d and-~f(n/d,d)or n>d<1and[f(n-1),print(f(n,3)*'Fizz'+f(n,5)*'Buzz'or n)]

Try it online!

-1 byte thanks to Mukundan314

-1 byte thanks to cnln

If we can just return the result for a single number:

Python 3, 72 bytes

lambda n:g(n,3)*'Fizz'+g(n,5)*'Buzz'or n
g=lambda i,d:i%d<1and-~g(i/d,d)

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ You can save a byte by using / instead of // in g \$\endgroup\$
    – cnln
    Apr 17 at 13:37
6
\$\begingroup\$

R 4.1 and above, 108 97 92 bytes

5 bytes down thanks to giuseppe.

\(x)(1:x~1:x)<"
"
`<`=paste0
i=ifelse
`~`=\(x,y="")i(x%%3,i(x%%5,y,"Buzz"<~x/5),"Fizz"<~x/3)

This is a function, to call and print you need

cat(f(200),sep="")

Attempt it online

More bytes can be removed if just returning an array of strings without newlines is OK (ATO).

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Nice solution (+1), but you're not allowed to take the input as a variable; this should be either a function taking n as an argument, or a full program reading n from STDIN or command line args. See Defaults for Code Golf. Also, just FYI there's a site called Attempt This Online! (ATO) which is essentially a TIO clone that is maintained regularly and has newer languages; the creator of TIO has not been active on the internet for several years. \$\endgroup\$
    – noodle man
    Apr 10 at 12:11
  • \$\begingroup\$ @noodleman Thanks, converted to function call (and saved one byte while at it :-) \$\endgroup\$ Apr 10 at 13:16
  • 1
    \$\begingroup\$ welcome fellow R golfer :) We have some nice tips for golfing in R; I think this could get into the 90-byte range with a few improvements. \$\endgroup\$
    – Giuseppe
    Apr 10 at 13:44
  • 1
    \$\begingroup\$ @MartinModrák I was able to get it to 92 bytes, really only by three bytes, though, as the f= can be removed. \$\endgroup\$
    – Giuseppe
    Apr 10 at 14:57
  • 1
    \$\begingroup\$ The "array of strings without newlines" can be 86 though! \$\endgroup\$
    – Giuseppe
    Apr 10 at 14:57
5
\$\begingroup\$

sed -E, 87 84 bytes

This one takes the number of input lines for the number of lines to output. It outputs numbers as unary (if not Fizz or Buzz):

g
s/z*/zx/
h
:1
s/z(x+)\1\1$/zFizz\1/
t1
:2
s/z(x+)\1{4}$/zBuzz\1/
t2
s/z//
//s/x//g

It turned out three bytes could be saved by adding a z to the start of the line to avoid (^|z) plus backreference, when at the same time we add one x instead of incrementing newlines plus conversion.

Try it online!

It could be optimised down to 78 bytes, if FizzBuzzFizz would be allowed for 45 and the like.

\$\endgroup\$
4
\$\begingroup\$

05AB1E, 27 26 bytes

ENDÓ0Þ«2Lè”FizzÒÖ”#×JD?`þ,

Try it online.

Explanation:

E                           # Loop `N` in the range [1, (implicit) input]:
 N                          #  Push the current `N`
  D                         #  Duplicate `N`
   Ó                        #  Pop and push a list of exponents of its prime factorization
    0Þ«                     #  Merge an infinite list of 0s to it
       2L                   #  Push [1,2]
         è                  #  0-based index this 1 and 2 into the list of exponents
          ”FizzÒÖ”          #  Push dictionary string "Fizz Buzz"
                  #         #  Split it on spaces: ["Fizz","Buzz"]
                   ×        #  Repeat both the exponents amount of times
                    J       #  Join this pair of strings together
                     D      #  Duplicate it
                      ?     #  Pop and print this copy without newline
                       `    #  Pop and push its characters to the stack
                            #  (if the string was empty, it pops without pushing anything)
                        þ   #  Only leave the digits of the top item
                            #  ("z" will become ""; numbers remain unchanged)
                         ,  #  Then pop and print it with trailing newline as well

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”FizzÒÖ” is "Fizz Buzz".

Some minor notes:

  1. The 0-based \$1^{st}\$ and \$2^{nd}\$ exponents of the prime factorization are those for primes \$3\$ and \$5\$, a.k.a. the amount of times the number is evenly divisible by \$3\$ or \$5\$ respectively.
  2. The 0Þ« is necessary because 05AB1E has modular indexing. So for the lists with only a single or two items instead of \$\geq3\$, it would incorrectly retrieve that single or first item when indexing with the modular 0-based \$1\$ or \$2\$.
  3. The END...D?`þ, is to print the number if the J results in an empty string "" and print the string otherwise. An alternative that's 1 byte shorter would be EN...N‚éθ, or END...‚éθ,, but unfortunately those are limited to \$n\leq1001\$ and \$n\leq10001\$ respectively.
\$\endgroup\$
4
\$\begingroup\$

Jelly, 18 bytes

ọ3,5“¡Ṭ4“Ụp»ẋ"Fȯ)Y

A full program that accepts a positive integer and prints the FizzFizzFizzBuzz sequence.

Try it online!

How?

ọ3,5“¡Ṭ4“Ụp»ẋ"Fȯ)Y - Main Link: positive integer, N
                )  - for each n in [1..N]:
 3,5               -   [3, 5]
ọ                  -   {n} divisibility counts {[3,5]}
    “¡Ṭ4“Ụp»       -   ["Fizz", "Buzz"] (compressed list of lists of characters)
            ẋ"     -   zip {["Fizz", "Buzz"]} with repeat {divisibility counts}
              F    -   flatten
               ȯ   -   logical OR {n} 
                 Y - join with newline characters
                   - implicit, smashing print
\$\endgroup\$
4
\$\begingroup\$

In my solutions, the function is found verbatim in the full program.

C (gcc), 137 114 bytes (just function)

f(N){while(i++<N){for(j=i;j%3<1;j/=3)printf("Fizz");for(;j%5<1;j/=5)printf("Buzz");i-j||printf("%d",j);puts("");}}

C (gcc), 153 133 bytes

i,j;f(N){while(i++<N){for(j=i;j%3<1;j/=3)printf("Fizz");for(;j%5<1;j/=5)printf("Buzz");i-j||printf("%d",j);puts("");}}main(){f(200);}

Try it online!

\$\endgroup\$
12
3
\$\begingroup\$

Retina 0.8.2, 87 bytes

.+
$*¶

$.`
1A`
%(`.+
$*
+`^(\D*(1+))\2{4}$
Buz$1
+`^(\D*(1+))\2\2$
Fiz$1
z1*
zz
1+
$.&

Try it online! Explanation:

.+
$*¶

$.`
1A`
%(`

Loop over all the integers from 1 to n.

.+
$*

Convert to unary.

+`^(\D*(1+))\2{4}$
Buz$1

Prefix Buz for each time the integer can be divided by 5.

+`^(\D*(1+))\2\2$
Fiz$1

Prefix Fiz for each time the integer can be divided by 3.

z1*
zz

Double the zs and delete the 1s from lines that had at least one factor.

1+
$.&

Convert the remaining lines back to decimal.

\$\endgroup\$
3
\$\begingroup\$

Uiua 0.10.3, 42 bytes SBCS

∵(&p◌⍥:±⧻.♭▽:"Fizz"_"Buzz"/+⍉⊞=3_5°/×.)+1⇡

Explanation

+1⇡ # range [1 ... n]
∵(  # for each
  °/×.            # prime factorization
  ⊞=3_5           # table with 1s where 3s and 5s are
  /+⍉             # get number of factors equal to 3 and 5
  ▽:"Fizz"_"Buzz" # duplicate Fizz and Buzz that many times
  ♭               # flatten into one string
  ⍥:±⧻.           # if non-empty, flip stack
  &p◌             # drop the top of stack and print
)

Try on Uiua Pad!

(replacing /+⍉⊞= with gives normal FizzBuzz)

\$\endgroup\$
3
\$\begingroup\$

APL+WIN, 79 76 bytes.

Multi-line function shorter than one liner

Prompts for integer n

n←⎕
:for i :in ⍳n
((0=⍴t)↑i),t←∊(∊+/0=1|i÷(⊂3 5)*¨⍳⌈i*.5)/'Fizz' 'Buzz'
:end

Try it online! Thanks to Dyalog Classic

\$\endgroup\$
2
\$\begingroup\$

Charcoal, 31 bytes

EN∨ΣE⪪FiBu²×⁺λzz⌕X⁰⮌↨⊕ι⁺³⊗μ⁰I⊕ι

Try it online! Link is to verbose version of code. Explanation:

 N                              Input `n`
E                               Map over implicit range
      FiBu                      Literal string `FiBu`
     ⪪    ²                     Split into pairs
    E                           Map over pairs
             λ                  Current pair
            ⁺                   Concatenated with
              zz                Literal string `zz`
           ×                    Repeated by
                ⌕               Index of
                           ⁰    Literal integer `0` in
                  ⁰             Literal integer `0`
                 X              Vectorised raised to power
                      ι         Outer value
                     ⊕          Incremented
                    ↨           Converted to base
                          μ     Inner index
                         ⊗      Doubled
                       ⁺        Plus
                        ³       Literal integer `3`
                   ⮌            Reversed
   Σ                            Concatenate the results
  ∨                             Logical Or
                              ι Current value
                             ⊕  Incremented
                            I   Cast to string
                                Implicitly print
\$\endgroup\$
2
\$\begingroup\$

OCaml, 236 235 bytes

let rec d a b=if a mod b=0 then 1+d(a/b)b else 0
let rec r s i=if i=0 then""else s^(r s(i-1))
let f n=String.concat"\n"(List.init n(fun x->if((x+1)mod 3)*((x+1)mod 5)>0 then string_of_int(x+1)else(r"Fizz"(d(x+1)3))^(r"Buzz"(d(x+1)5))))

Attempt This Online!

First time golfing in a while, hoping to get more familiar with OCaml. First line counts clean divisions, second line implements string repetition, third line is pretty standard FizzBuzz.

  • -1 byte by not doing let y=x+1
\$\endgroup\$
2
\$\begingroup\$

Perl 5, 75 bytes

map{$r='';$_/=3,$r.=Fizz until$_%3;$_/=5,$r.=Buzz until$_%5;say$r||$_}1..<>

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Haskell, 109 bytes

n#d|n`mod`d<1=(last$"Fizz":["Buzz"|d>4])++(n`div`d)#d|1>0=""
l=[s++do[0|s<" "];show i|i<-[1..],s<-[i#3++i#5]]

Try it online!

...I don't like it either.

\$\endgroup\$
1
\$\begingroup\$

Ruby, 85 bytes

->n{(1..n).map{|x|a,b=[3,5].map{|d|x.to_s(d)[/0*$/].size};a+b>0?"Fizz"*a+"Buzz"*b:x}}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 143 bytes

f=n=>{n-1&&f(n-1);console.log(n%3&&n%5?n:!(n%3)?'Fizz'.repeat(g(n,3,0)):''+!(n%5)?'Buzz'.repeat(g(n,5,0)):'')}
g=(n,f,i)=>!(n%f)?g(n/f,f,++i):i

Attempt This Online!

\$\endgroup\$
1
\$\begingroup\$

Perl 5, 76 bytes

sub c{$_%$_[0]?0:($_/=$_[0],1+&c)}say'Fizz'x c(5).'Buzz'x c(3)||$_ for 1..<>

Try it online!

(I was tempted to post eval<> (6 bytes) with some carefully crafted input, but I suspect there's already a rule against that.)

\$\endgroup\$
1
  • \$\begingroup\$ I'm not sure exactly which standard loophole covers this as there are two that are similar; one gives the example of giving eval (or its equivalent) as your program, while the other disallows input other than that given by the question. \$\endgroup\$
    – Neil
    Apr 11 at 23:55
1
\$\begingroup\$

C# (Hussy.Net), 92 bytes

Gr(N).E(i=>{string e = null;F(i,Dvb3,Dv3,_=>e+="Fizz");F(i,Dvb5,Dv5,_=>e+="Buzz");W(e,i);});

Explanation

Gr(N)                            // Generate a range from 1 to N.
   .E(i => {                     // Iterate over each element in the range.

    string e = null;             // Create a variable to store output in.
    F(                           // Method imitating a for loop.
      i,                         // Start at the current value for i.
        Dvb3,                    // Iterate while i % 3 == 0.
             Dv3,                // Divide the iterator by 3.
                 _=>e+="Fizz");  // Append fizz to e.


    // Same as previous chunk but for buzz.
    F(i, Dvb5, Dv5, _ => e += "Buzz");


    W(e, i);                     // Write e if it is not null, otherwise i.
});

Python 3, 124 bytes

for i in range(1,n+1):
    f=b=0;x=y=i
    while x%3<1:f+=1;x/=3
    while y%5<1:b+=1;y/=5
    print('Fizz'*f+'Buzz'*b or i)

Try it online!

C# (.NET Core), 130 bytes

for(int i=1;i<=n;i++){int f=i,b=i;string e=null;for(;f%3<1;f/=3)e+="Fizz";for(;b%5<1;b/=5)e+="Buzz";Console.WriteLine(e??$"{i}");}

Try it online!

Rust, 153 bytes

for i in 1..=200{let mut f=i;while f%3==0{print!("Fizz");f/=3;}let mut b=i;while b%5==0{print!("Buzz");b/=5;}if i%3>0&&i%5>0{print!("{}",i);}println!();}

Try it online!

\$\endgroup\$
2
1
\$\begingroup\$

Python 3, 157 bytes

This is my best go without looking at the other solutions. Thanks to @SectorCorrupter for their tip on using * for string manipulation. My solution makes use of the fact that both 3 and 5 are prime, so dividing by one does not remove the other as a factor.

for x in range(1,n+1):
    y=z=0;s=f'{x}'*bool(x%3and x%5)
    while x%3<1and x>0:x//=3;y+=1
    while x%5<1and x>0:x//=5;z+=1
    print(s+'Fizz'*y+'Buzz'*z)

Try it online!

With the lambda function from @Jitse's solution, I can get it down to 126 125 bytes (-1 byte thanks to @Hazel へいぜる!):

g=lambda i,d:i%d<1and-~g(i/d,d)
for x in range(1,n+1):
    s=f'{x}'*bool(x%3and x%5)
    print(s+'Fizz'*g(x,3)+'Buzz'*g(x,5)

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can squeeze an additional byte out of lambda solution with i/d instead of i//d. \$\endgroup\$ Apr 16 at 3:19
1
\$\begingroup\$

sed 4.2.2 + coreutils factor, 65 bytes

s/^/factor /e
s/ 3\b/Fizz/g
s/ 5\b/Buzz/g
/z/s/[0-9 :]//g
s/:.*//

Try it online!

\$\endgroup\$
1
\$\begingroup\$

PowerShell, 113 bytes

function F($N){1..$N|%{$i=$_;for($j=$i;$j%3-eq0;$j/=3){'Fizz'};for(;($j%5)-eq0;$j/=5){'Buzz'};if($i-$j-eq0){$_}}}

Try it online!

PowerShell, 120 bytes

function FizzBuzz($N){1..$N|%{$i=$_;for($j=$i;$j%3-eq0;$j/=3){'Fizz'};for(;($j%5)-eq0;$j/=5){'Buzz'};if($i-$j-eq0){$_}}}

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You could rename the function FizzBuzz to F to save some bytes \$\endgroup\$
    – noodle man
    Apr 17 at 17:33
  • \$\begingroup\$ @noodleman duuuuuuhhh thought I'd done that! Cheers :-) \$\endgroup\$ Apr 22 at 9:53
1
\$\begingroup\$

Rust, 124 bytes

|n|for mut i in 1..=n{if i%3*i%5>0{print!("{i}")}while i%3<1{i/=3;print!("Fizz")}while i%5<1{i/=5;print!("Buzz")}println!()}

Attempt This Online!

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to CGCC, nice first submission! \$\endgroup\$
    – noodle man
    Apr 22 at 14:54
0
\$\begingroup\$

Perl 5, 60 bytes

@x[++$q*3,$q*5]=(Fizz.$_,$_.Buzz),print$_||$q,$/for@x[1..<>]

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.