Created
June 17, 2016 05:08
-
-
Save dsomel21/71d235d1f574074aefefe6e88e10cd77 to your computer and use it in GitHub Desktop.
The Classic Fizz Buzz! But with a twist!
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
| def fizzbuzz_value(i) | |
| if i % 5 == 0 && i % 3 == 0 | |
| "FizzBuzz" | |
| elsif i % 5 == 0 | |
| "Buzz" | |
| elsif i % 3 == 0 | |
| "Fizz" | |
| else | |
| i | |
| end | |
| end | |
| def fizzbuzz (starting, ending) | |
| starting.upto(ending) {|i| puts fizzbuzz_value(i)} | |
| end | |
| fizzbuzz(1, 31) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment