Skip to content

Instantly share code, notes, and snippets.

@nerocrux
Created May 9, 2012 14:44
Show Gist options
  • Save nerocrux/2645009 to your computer and use it in GitHub Desktop.
Save nerocrux/2645009 to your computer and use it in GitHub Desktop.
fizzbuzz without mod (c++)
#include <stdio.h>
void fizzbuzz(int num_fizz, int num_buzz, int num_fizzbuzz, int counter)
{
if(num_fizzbuzz == 15) {printf("fizzbuzz "); num_fizz=0; num_buzz=0; num_fizzbuzz=0;}
else if(num_fizz == 3) {printf("fizz "); num_fizz=0;}
else if(num_buzz == 5) {printf("buzz "); num_buzz=0;}
else printf("%d ", counter);
if (counter < 100) fizzbuzz(++num_fizz, ++num_buzz, ++num_fizzbuzz, ++counter);
}
main ()
{
fizzbuzz(1,1,1,1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment