Created
January 15, 2014 14:41
-
-
Save elikem/8437446 to your computer and use it in GitHub Desktop.
solving for fizzbuzz
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
| #!/usr/bin/env ruby | |
| fizz = 3 | |
| buzz = 5 | |
| puts 'Please enter an integer: ' | |
| number = gets.to_i | |
| puts '' | |
| puts 'Start' | |
| 1.upto(number) do |n| | |
| if n % fizz == 0 | |
| if n % buzz == 0 | |
| puts 'fizzbuzz' | |
| else | |
| puts 'fizz' | |
| end | |
| elsif n % buzz == 0 | |
| puts 'buzz' | |
| else | |
| puts n | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment