Last active
October 9, 2015 06:28
-
-
Save pkamb/3454452 to your computer and use it in GitHub Desktop.
fizzBuzz in 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
// 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