using System.Diagnostics;
public static int InputInt(string prompt)
Console.Write("Enter " + prompt + ":");
return Convert.ToInt32(Console.ReadLine());
public static void Main(string[] args)
int side1 = InputInt("one side length");
int side2 = InputInt("another side length");
int nTake = InputInt("the number of pieces to remove");
Trace.Assert(side1 > 0 && side2 > 0 && nTake > 0);
if (nTake % side1 == 0 || nTake % side2 == 0 && nTake <= side1 * side2){