Skip to content

Instantly share code, notes, and snippets.

@micedreams
Created November 12, 2023 10:57
Show Gist options
  • Save micedreams/80824d93dc5cb6f0e82afe4f48787c05 to your computer and use it in GitHub Desktop.
Save micedreams/80824d93dc5cb6f0e82afe4f48787c05 to your computer and use it in GitHub Desktop.
Ruby Fizbuz
def fizz_buzz(n)
if n % 10 == 0
"FizzBuzz"
elsif n % 5 == 0
"Buzz"
elsif n % 2 == 0
"Fizz"
else
n
end
end
1.upto(100) do |n|
puts fizz_buzz(n)
end
require_relative 'fizbuz'
describe Fizbuz do
it "number factorial of 2 & 5" do
input_number = 10
output = fizz_buzz(input_number)
expect(output).to eq("FizzBuzz")
end
it "number factorial of 5" do
number % 5 == 0
puts "Buzz"
end
it "number factorial of 2 " do
number % 2 == 0
puts "Fizz"
end
it "else" do
puts number
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment