Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I divide a value and if the remainder is not 0 I want the closest possible divisor without remainder.


I have:
$100 \% 48 = 4$

Now I am looking for the next value which divide 100 wihtout remainder. Result: $50$
$100 \% 50 = 0%$

Just another example:
$14 \% 6 = 2$
Result $7$
$14 \% 7 = 0$

Does anyone know how to calculate this?

share|cite|improve this question
It seems that you know how to calculate this. Are you looking for some other way to calculate it? – vadim123 Mar 17 '14 at 15:20
No, I don´t know. My "results" are just guessed. – Viatorus Mar 17 '14 at 15:22
If there were an easy way of doing this in general we'd be able to factorise large numbers using the method. And no-one knows an easy way to do that. – Mark Bennet Mar 17 '14 at 16:12
up vote 0 down vote accepted
  1. Calculate 100%48. If the answer is zero, stop. Otherwise:
  2. Calculate 100%49. If the answer is zero, stop. Otherwise:
  3. Calculate 100%50. If the answer is zero, stop. Otherwise:


share|cite|improve this answer
doing so you'll find an integer $ x \text{ such that } x \equiv 0 \text{ mod } M$, but not the nearest...e.g maybe it was $47$ – sirfoga Mar 17 '14 at 15:26
Okay, well I hoped there is a better way to calculate this. But thank you anyway. – Viatorus Mar 17 '14 at 15:26
If you want the nearest and allow those less than 48, then try: 48, 49, 47, 50, 46, 51, 45, etc. – vadim123 Mar 17 '14 at 15:29

I know this is old, but I was looking for an answer to the same question and I think I figured it out. Perform your initial division (e.g. 100/48=2.08333...), round the quotient to the nearest integer (2.08333... -> 2), divide that into the original number, and that gives you the closest divisor that evenly divides into the dividend (100/2=50). Or for your second example, 14/6=2.333..., 2.333->2, 14/2=7. This won't always give you an integer divisor, however.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.