Tracks
/
R
R
/
Exercises
/
Fizz Buzz
Fizz Buzz

Fizz Buzz

Easy

Instructions

Print numbers from 1 to n with the following exceptions:

  1. When a number is a multiple of 3, then print "Fizz"
  2. When a number is a multiple of 5, then print "Buzz"
  3. When a number is both a multiple of 3 and a multiple of 5, then print "Fizz Buzz"

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

Last updated 21 October 2021
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 35 exercises, and real human mentoring, all for free.