Tracks
/
R
R
/
Exercises
/
Fizz Buzz
Fizz Buzz

Fizz Buzz

Easy

Instructions

Print numbers from 1 to n with the following rules:

  1. When the number is a multiple of 3, print "Fizz"
  2. When the number is a multiple of 5, print "Buzz"
  3. When the number is both a multiple of 3 and a multiple of 5, print "Fizz Buzz"
  4. When the number is not a multiple of 3 or 5, print the number

The output should be a vector of strings, such as, "1" "2" "Fizz" "4" "Buzz" ...

Edit via GitHub The link opens in a new window or tab
R Exercism

Ready to start Fizz Buzz?

Sign up to Exercism to learn and master R with 47 exercises, and real human mentoring, all for free.