Created
February 26, 2015 14:52
-
-
Save chrisswong/ba83aa78f92bfd2cf322 to your computer and use it in GitHub Desktop.
FizzBuzz Test in Obj-C (Recursion)
This file contains hidden or 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
printFizzBallWithNumber(1 , 100); | |
void printFizzBallWithNumber(int startNumber, int endNumber) { | |
if (startNumber <= endNumber) { | |
int i = startNumber; | |
// | |
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); | |
} | |
startNumber++; | |
printFizzBallWithNumber( startNumber , endNumber); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment