Skip to main content
3 of 4
edited body
Larry Bagel
  • 4.2k
  • 4
  • 9

Nth FizzBuzz Number

Introduction

Everyone knows the FizzBuzz sequence. It goes something like this:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
.
.
.

In case you don't know, if the number is divisible by 3, it's Fizz. If it is divisible by 5, it's Buzz. If it is divisible by both, it's FizzBuzz. If it is not divisible by both, it's just the original number.

Task

Take two inputs separated by spaces, for example

Fizz 3

For this specific example input, you should output 9, the third Fizz. To be more general, take a word and a number separated by spaces, output the numberth word.

The word input may be Number, and in this case, you should output the numberth number in the FizzBuzz sequence that is not Fizz, Buzz, or FizzBuzz.

Test Cases

Fizz 3 => 9
Buzz 4 => 25
FizzBuzz 2 => 30
Number 312 => 586

Scoring

Shortest code wins!

Rules

  • No standard loopholes.

Meta

  • Feedback?

Todos

  • Add more test cases
Larry Bagel
  • 4.2k
  • 4
  • 9