Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # I suck but I heard about this thing called "FizzBuzz" which is apparently an interview question, so I consider it to be enough to get me a job in ruby (lol)
- # Expected output: if a number is divisable by 3, then print "Fizz", same for the number 5 except the word is "Buzz"
- # FizzBuzz should be printed if the number is divisable by both.
- for i in (1..100)
- if #{i}/3 == 0 && #{i}/5 == 0
- puts "FizzBuzz"
- elsif #{i}/3 == 0
- puts "Fizz"
- elsif #{i}/5 == 0
- puts "Buzz"
- else
- puts "#{i}"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement