Skip to content

Instantly share code, notes, and snippets.

@pkamb
Last active October 9, 2015 06:28
Show Gist options
  • Save pkamb/3454452 to your computer and use it in GitHub Desktop.
Save pkamb/3454452 to your computer and use it in GitHub Desktop.
fizzBuzz in Objective-C
// FizzBuzz in Objective-C
// By Peter Kamb
// Seattle, WA
- (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:@"%i", i];
}
NSLog(@"%@", output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment