Skip to content

Instantly share code, notes, and snippets.

@chrisswong
Last active August 29, 2015 14:16
Show Gist options
  • Save chrisswong/aab2321ad88c6d0383cd to your computer and use it in GitHub Desktop.
Save chrisswong/aab2321ad88c6d0383cd to your computer and use it in GitHub Desktop.
FizzBuzz Test in Obj-C (for loop)
for (int i = 1 ; i <= 100; i++) {
if ( i % 3 == 0 || i % 5 == 0 ) {
if (i % 3 == 0 && i % 5 == 0 ) {
NSLog(@"FizzBuzz");
}
else {
if (i % 3 == 0) {
NSLog(@"Fizz");
}
if (i % 5 == 0) {
NSLog(@"Buzz");
}
}
} else {
NSLog(@"%d\n", i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment