Advertisement
scottashipp

Find Multiples of M Between X and Y, Brute Force

Feb 26th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.19 KB | None | 0 0
  1.   int howManyMultiplesOfMBetweenXAndY(int m, int x, int y) {
  2.     int count = 0;
  3.     for (int i = x; i <= y; i++) {
  4.       if (i % m == 0) {
  5.         count++;
  6.       }
  7.     }
  8.     return count;
  9.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement