Skip to content

Instantly share code, notes, and snippets.

@omorgan7
Last active August 13, 2017 09:00
Show Gist options
  • Save omorgan7/2eeb0a2849289cb9203c229ddd5cbcf7 to your computer and use it in GitHub Desktop.
Save omorgan7/2eeb0a2849289cb9203c229ddd5cbcf7 to your computer and use it in GitHub Desktop.
#include<iostream>
bool isMultiple(int n,int divisor) {
return n % divisor == 0;
}
int main() {
for (int i = 1; i <= 10000000; i++) {
if (isMultiple(i, 3) && isMultiple(i, 5)) {
std::cout<<"FizzBuzz"<<"\n";
} else if (isMultiple(i, 3)) {
std::cout<<"Fizz"<<"\n";
} else if (isMultiple(i, 5)) {
std::cout<<"Buzz"<<"\n";
} else {
std::cout<<i<<"\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment