Noam_15

IsInMultiplicationTable

Dec 26th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1.         static bool IsInMultiplicationTable(int checkedNum, int tableSize)
  2.         {
  3.             if (checkedNum == 1)
  4.             {
  5.                 return true;
  6.             }
  7.  
  8.             if (checkedNum <= tableSize * tableSize && checkedNum > 0)
  9.             {
  10.                 for (int divisionNum = 2; divisionNum <= tableSize; divisionNum++)
  11.                 {
  12.                     if ((checkedNum <= divisionNum * tableSize) &&
  13.                         (checkedNum % divisionNum == 0))
  14.                     {
  15.                         return true;
  16.                     }
  17.                 }
  18.             }
  19.  
  20.             return false;
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment