// a short fizzbuzz, can make smaller by removing spaces
#include <iostream>
int i;
int main() {
for (auto &o=std::cout; ++i < 101; o<<'
')
i%3? o : o << "Fizz",
i%5? i%3? o << i :o : o << "Buzz";
}
#include <iostream>
using namespace std;
void fizzBuzz(int n)
{
for (int i = 1; i <= n; i++)
{
if (i % 3 != 0 && i % 5 != 0) //check if the number is neither a multiple of 5 nor 3
{
cout << i << endl;
}
else if (i % 3 == 0) //check if the number is a multiple of 3
{
if (i % 5 == 0) //check if the number is also a multiple of 5
{
cout << "FizzBuzz" << endl;
}
else
{
cout << "Fizz" << endl;
}
}
else
{
cout << "Buzz" << endl; //if the number didn't satisfy the first if statement or the else if statement then it is a multiple of 5
}
}
}
int main()
{
fizzBuzz(15);
return 0;
}