Skip to content

Instantly share code, notes, and snippets.

@superjessi
Created April 12, 2012 14:24
Show Gist options
  • Save superjessi/2367664 to your computer and use it in GitHub Desktop.
Save superjessi/2367664 to your computer and use it in GitHub Desktop.
FizzBuzz - Objective-C
- (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