Skip to content

Instantly share code, notes, and snippets.

@alefcarlos
Last active January 8, 2019 04:48
Show Gist options
  • Save alefcarlos/35832356cbe4afe3f81adb3dfba49a56 to your computer and use it in GitHub Desktop.
Save alefcarlos/35832356cbe4afe3f81adb3dfba49a56 to your computer and use it in GitHub Desktop.
public static bool IsMultipleOf(int y, int x)
{
//Chek if value is negative
if (x < 0 || y < 0)
throw new ArgumentException("Essa operação só é possível com números naturais.");
//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