Skip to content

Instantly share code, notes, and snippets.

@omorgan7
Last active August 13, 2017 09:00
Show Gist options
  • Save omorgan7/74164997ba36c815f837c8a49281368a to your computer and use it in GitHub Desktop.
Save omorgan7/74164997ba36c815f837c8a49281368a 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++) {
std::string text = std::string();
if (isMultiple(i, 3)) {
text += "Fizz";
}
if (isMultiple(i, 5)) {
text += "Buzz";
}
if(text.length() > 0){
std::cout<<text<<"\n";
}
else{
std::cout<<i<<"\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment