Skip to content

Instantly share code, notes, and snippets.

@codeswimmer
Forked from pkamb/fizzBuzzObjectiveC
Created August 24, 2012 19:04
Show Gist options
  • Save codeswimmer/3454460 to your computer and use it in GitHub Desktop.
Save codeswimmer/3454460 to your computer and use it in GitHub Desktop.
fizzBuzz in Objective-C
- (void)fizzBuzzObjectiveC
{
for(int i = 1; i <= 100; i++) {
NSString *output = @"";
if(i % 3 == 0)
output = [output stringByAppendingString:@"Fizz"];
if(i % 5 == 0)
output = [output stringByAppendingString:@"Buzz"];
if([output length] == 0)
output = [NSString stringWithFormat:@"%d", i];
NSLog(@"%@", output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment