Skip to content

Instantly share code, notes, and snippets.

@alefcarlos
Last active January 8, 2019 01:05
Show Gist options
  • Save alefcarlos/b329f28d17652e9b1d32e2aa9b2b0b1a to your computer and use it in GitHub Desktop.
Save alefcarlos/b329f28d17652e9b1d32e2aa9b2b0b1a to your computer and use it in GitHub Desktop.
/// <summary>
/// Validadtes if a value is multiple of other number
/// </summary>
/// <param name="y">The desired multiple.</param>
/// <param name="x">Value to check.</param>
/// <returns>Returns true if value is multiple of multiple</returns>
public static bool IsMultipleOf(int y, int x)
{
//Check possible DivisionByZero
if (y == 0)
throw new ArgumentException("O múltiplo deve ser maior do que 0.", nameof(y));
//A number is multiple if the remainder value is 0.
return (x % y) == 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment