Skip to content

Instantly share code, notes, and snippets.

@jangorecki
Last active October 20, 2015 10:17
Show Gist options
  • Save jangorecki/ef2b908a6ad46a13a5e4 to your computer and use it in GitHub Desktop.
Save jangorecki/ef2b908a6ad46a13a5e4 to your computer and use it in GitHub Desktop.
R FizzBuzz
f = seq(3,100,3)
b = seq(5,100,5)
fb = f[f %in% b]
f = f[!f %in% fb]
b = b[!b %in% fb]
x = as.character(1:100)
x[f] = "Fizz"
x[b] = "Buzz"
x[fb] = "FizzBuzz"
cat(x, sep = "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment