#C6534. FizzBuzz Sequence Generator

    ID: 50305 Type: Default 1000ms 256MiB

FizzBuzz Sequence Generator

FizzBuzz Sequence Generator

This problem requires you to generate a FizzBuzz sequence from 1 to n. For each integer i (where 1 ≤ i ≤ n):

  • If \( i \bmod 3 = 0 \) and \( i \bmod 5 = 0 \) then output FizzBuzz.
  • If \( i \bmod 3 = 0 \) then output Fizz.
  • If \( i \bmod 5 = 0 \) then output Buzz.
  • Otherwise, output the number i.

If the input integer n is less than 1, the sequence is empty (i.e. no output).

The rules can be summarized using LaTeX as: \( \text{if } n < 1 \quad \text{then output nothing, else for } 1 \le i \le n:\\ \quad \text{if } i \bmod 3 = 0 \text{ and } i \bmod 5 = 0, \text{ output } \texttt{FizzBuzz};\\ \quad \text{if } i \bmod 3 = 0, \text{ output } \texttt{Fizz};\\ \quad \text{if } i \bmod 5 = 0, \text{ output } \texttt{Buzz};\\ \quad \text{otherwise, output } i. \)

inputFormat

The input is read from stdin and consists of a single integer n. The number n determines the end of the sequence. If n is less than 1, no output should be produced.

outputFormat

Print the elements of the FizzBuzz sequence to stdout, each on a new line. For each integer i (1 ≤ i ≤ n):

  • If i is divisible by both 3 and 5, print "FizzBuzz".
  • If i is divisible by 3 only, print "Fizz".
  • If i is divisible by 5 only, print "Buzz".
  • Otherwise, print the integer i.
## sample
1
1