Created
April 14, 2024 23:08
-
-
Save RichardsonColin/26575c7ae8f30ab3d285a97176a5435a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# -- Directions -- | |
# | |
# 1. Make a list of numbers from 1-100 inclusive | |
# 2. Loop through those numbers | |
# 3. For each number: | |
# a. if it's divisible by 3, puts "Fizz" | |
# b. if it's divisible by 5, puts "Buzz" | |
# c. if it's divisible by 3 && 5, puts "FizzBuzz" | |
# d. otherwise, puts the Number | |
# | |
# ---------------------------------------------- | |
# | |
# -- Hint -- | |
# | |
# if ... | |
# ... | |
# elsif n % 3 == 0 | |
# puts "Fizz" | |
# else | |
# ... | |
# end | |
# | |
# ---------------------------------------------- | |
# | |
# Example on how to construct the control flow: | |
# - https://www.educative.io/answers/how-to-write-an-if-else-condition-in-ruby | |
# | |
# Starter code below | |
# loop through numbers 1 to 15 | |
(1..15).each do |num| | |
# 'num' references each number in the loop (1 to 15) | |
if num % 3 == 0 | |
puts "Fizz" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment