Skip to content

Instantly share code, notes, and snippets.

@patmifsud
Created October 12, 2021 21:52
Show Gist options
  • Select an option

  • Save patmifsud/bc3d16b1bb7ee68c37fd9a85f3cc9afc to your computer and use it in GitHub Desktop.

Select an option

Save patmifsud/bc3d16b1bb7ee68c37fd9a85f3cc9afc to your computer and use it in GitHub Desktop.

Warmup - Raindrops

Write a program using Ruby that will take a number (eg 28 or 1755 or 9, etc) and output the following:

  • If the number contains 3 as a factor, output 'Pling'.
  • If the number contains 5 as a factor, output 'Plang'.
  • If the number contains 7 as a factor, output 'Plong'.
  • If the number does not contain 3, 5, or 7 as a factor, output the number as a string.

Examples

  • 28 has 7 as a factor. In raindrop-speak, this would be a simple "Plong".
  • 1755 has 3 and 5 as factors. In raindrop-speak, this would be a "PlingPlang".
  • 34 has neither 3, 5 nor 7 as a factor. Raindrop-speak doesn't know what to make of that, so it just goes with the straightforward "34".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment