forked from CoderAcademy-BRI/ruby-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11_fizzbuzz.rb
More file actions
45 lines (36 loc) · 976 Bytes
/
Copy path11_fizzbuzz.rb
File metadata and controls
45 lines (36 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# FizzBuzz
# Don't look this one up until you complete it yourself!
# It's a common interview question and there will be plenty
# of spoilers on the interwebs.
# Difficulty:
# 4/10
# This is a trivial question with many simple solutions.
# Try to write the least amount of code as possible.
# Write a program that prints the numbers from 1 to 100.
# But for multiples of three print “Fizz” instead of the
# number and for the multiples of five print “Buzz”. For
# numbers which are multiples of both three and five
# print “FizzBuzz”.
# Check your solution by running: ruby 11_fizzbuzz.rb
# Example:
# 1
# 2
# Fizz
# 4
# Buzz
# ...etc
# Your code here
def fizzbuzz(number)
if number % 15 == 0
return "FizzBuzz"
elsif number % 3 == 0
return "Fizz"
elsif number % 5 == 0
return "Buzz"
else
return number.to_s
end
end
for i in (0..10000)
puts fizzbuzz(i)
end