Skip to content

Instantly share code, notes, and snippets.

@maxkramer
Created August 20, 2011 17:26
Show Gist options
  • Save maxkramer/1159377 to your computer and use it in GitHub Desktop.
Save maxkramer/1159377 to your computer and use it in GitHub Desktop.
FizzBuzz - Objective-C
- (NSArray *) fizzBuzzFrom:(unsigned int)from To:(unsigned int) to {
int i = from;
NSMutableArray *array = [NSMutableArray arrayWithCapacity:to];
while (i <= to) {
NSString *string = (++i % 15? (i%5? (i%3 ? [NSString stringWithFormat:@"%d", i] : @"Fizz") : @"Buzz") : @"FizzBuzz");
[array addObject:string];
string = nil;
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment