Created
April 12, 2012 14:24
-
-
Save superjessi/2367664 to your computer and use it in GitHub Desktop.
FizzBuzz - Objective-C
This file contains 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
- (void)fizzBuzzFrom:(int)bottom to:(int)top | |
{ | |
for (int i = bottom; i <= top; i++) { | |
NSString *fizzBuzzString; | |
if (i % 3 == 0 && i % 5 == 0) { | |
fizzBuzzString = @"FizzBuzz"; | |
} else if (i % 3 == 0) { | |
fizzBuzzString = @"Fizz"; | |
} else if (i % 5 == 0) { | |
fizzBuzzString = @"Buzz"; | |
} else { | |
fizzBuzzString = [NSString stringWithFormat:@"%i", i]; | |
} | |
NSLog(@"%@", fizzBuzzString); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment