Skip to content

Instantly share code, notes, and snippets.

@ykjchen
ykjchen / FizzBuzz
Created December 6, 2013 10:43
Fizz Buzz in C/ObjC. The console will log each number between 1 and toValue (inclusive), substituting multiples of three with "fizz", multiples of five with "buzz", and multiples of both three and five with "fizz buzz."
/*!
* The console will log each number between 1 and toValue (inclusive),
* substituting multiples of three with "fizz", multiples of five with "buzz",
* and multiples of both three and five with "fizz buzz."
*/
void fizzBuzz(int toValue)
{
for (int i = 1; i <= toValue; i++) {
BOOL isFizz = (i % 3 == 0);
BOOL isBuzz = (i % 5 == 0);