Skip to content

Instantly share code, notes, and snippets.

@Benhgift
Created May 18, 2012 01:16
Show Gist options
  • Select an option

  • Save Benhgift/2722560 to your computer and use it in GitHub Desktop.

Select an option

Save Benhgift/2722560 to your computer and use it in GitHub Desktop.
fizzBuzz
//returns 3 if divisible by 3, 5 if divisible by 5, and 0 if neither and 10 if both
int fizzBuzz(int num) {
int temp;
if(num%3 == 0)
temp = 3;
if(num%5 == 0)
temp += 5;
if(temp == 3)
return temp;
else if(temp == 5)
return temp;
else if(temp == 8)
return 10; //divisible by both
else
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment