Skip to content

Commit

Permalink
fizzbuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
a-abdellatif98 committed Feb 16, 2022
1 parent d3dbb03 commit e58015f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fizzBuzz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def fizz_buzz(n)
answer = []
(1..n).to_a.map do |x|
if x % 3 == 0 && x % 5 == 0
"FizzBuzz"
elsif x % 3 == 0
"Fizz"
elsif x % 5 == 0
"Buzz"
else
x.to_s
end
end
end


0 comments on commit e58015f

Please sign in to comment.