public void main()
{
FizzTheBuzz(["Fizz", "Buzz", "FizzBuzz"], [3, 5, 15], 100);
}
/// <summary>
/// Takes a collection of strings and ints.
/// If any number below count is divisible by any of the conditions, it outputs
/// the matching text in the output array. The length of output and conditions
/// must be the same.
/// </summary>
/// <param name="outputs">What to say if there's a match</param>
/// <param name="conditions">On what numbers do you want to say an output?</param>
/// <param name="count">How high to you want to count</param>
public void FizzTheBuzz(string[] outputs, int[]conditions, int count)
{
if (output.Length != conditions.Length)
{
Console.WriteLine("The lengths of outputs and conditions don't match.");
return;
}
for (int i = 0; i < count; i++)
for (int i1 = 0; i1 < conditions.Length; i1++)
Console.WriteLine((i % conditions[i1] == 0) ? outputs[i1] : i);
}
EDIT: what is wrong with me? Maybe it's just because it's Saturday and I don't want to do work.
View all comments
1
u/mcdileo Jan 18 '14 edited Jan 18 '14
Just because:
EDIT: what is wrong with me? Maybe it's just because it's Saturday and I don't want to do work.