Find the next divisor without remainder [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












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



Example:



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













closed as off-topic by user21820, Xander Henderson, Adrian Keister, amWhy, Jack D'Aurizio♦ Sep 1 at 14:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Xander Henderson, amWhy, Jack D'Aurizio
If this question can be reworded to fit the rules in the help center, please edit the 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






  • 2




    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










  • Isn't there an easy way to do this? I'm confused.
    – bozdoz
    yesterday














up vote
2
down vote

favorite
1












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



Example:



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













closed as off-topic by user21820, Xander Henderson, Adrian Keister, amWhy, Jack D'Aurizio♦ Sep 1 at 14:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Xander Henderson, amWhy, Jack D'Aurizio
If this question can be reworded to fit the rules in the help center, please edit the 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






  • 2




    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










  • Isn't there an easy way to do this? I'm confused.
    – bozdoz
    yesterday












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





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



Example:



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













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



Example:



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?







elementary-number-theory divisibility






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Mar 17 '14 at 15:14









Viatorus

12113




12113




closed as off-topic by user21820, Xander Henderson, Adrian Keister, amWhy, Jack D'Aurizio♦ Sep 1 at 14:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Xander Henderson, amWhy, Jack D'Aurizio
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by user21820, Xander Henderson, Adrian Keister, amWhy, Jack D'Aurizio♦ Sep 1 at 14:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Xander Henderson, amWhy, Jack D'Aurizio
If this question can be reworded to fit the rules in the help center, please edit the 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






  • 2




    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










  • Isn't there an easy way to do this? I'm confused.
    – bozdoz
    yesterday
















  • 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






  • 2




    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










  • Isn't there an easy way to do this? I'm confused.
    – bozdoz
    yesterday















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




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




No, I don´t know. My "results" are just guessed.
– Viatorus
Mar 17 '14 at 15:22




2




2




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




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












Isn't there an easy way to do this? I'm confused.
– bozdoz
yesterday




Isn't there an easy way to do this? I'm confused.
– bozdoz
yesterday










2 Answers
2






active

oldest

votes

















up vote
1
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:

etc.






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







  • 1




    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


















up vote
2
down vote













I had the same question when I found this, so here's some sample (python) code that would find the nearest divisor with no remainder.



Num = 636 # Numerator we are seeking to divide with no remainder
Den = 8 # Initial denominator
max_iters = 15 # caps the maximum loops
iters = 1 # initialize counter
Deni = Dend = Den # vars for searching increasing and decreasing denominators

while Num%Den != 0:
Deni +=1 # searching increased vals
if Dend > 0 : Dend -=1 # searching decreased vals, but check 0 condition
if Num%Dend ==0: # found a 0 remainder denominator
Den = Dend # assign found denominator
break
elif Num%Deni ==0: # found a 0 remainder denominator
Den = Deni # assign found denominator
break
elif iters >= max_iters: # check loop count
break
iters+=1


Not as clean as a built in function, but hopefully it helps the next person.






share|cite|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    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:

    etc.






    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







    • 1




      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















    up vote
    1
    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:

    etc.






    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







    • 1




      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













    up vote
    1
    down vote



    accepted







    up vote
    1
    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:

    etc.






    share|cite|improve this answer












    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:

    etc.







    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered Mar 17 '14 at 15:23









    vadim123

    74.3k895185




    74.3k895185











    • 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







    • 1




      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

















    • 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







    • 1




      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
















    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





    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





    1




    1




    Okay, well I hoped there is a better way to calculate this. But thank you anyway.
    – Viatorus
    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





    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











    up vote
    2
    down vote













    I had the same question when I found this, so here's some sample (python) code that would find the nearest divisor with no remainder.



    Num = 636 # Numerator we are seeking to divide with no remainder
    Den = 8 # Initial denominator
    max_iters = 15 # caps the maximum loops
    iters = 1 # initialize counter
    Deni = Dend = Den # vars for searching increasing and decreasing denominators

    while Num%Den != 0:
    Deni +=1 # searching increased vals
    if Dend > 0 : Dend -=1 # searching decreased vals, but check 0 condition
    if Num%Dend ==0: # found a 0 remainder denominator
    Den = Dend # assign found denominator
    break
    elif Num%Deni ==0: # found a 0 remainder denominator
    Den = Deni # assign found denominator
    break
    elif iters >= max_iters: # check loop count
    break
    iters+=1


    Not as clean as a built in function, but hopefully it helps the next person.






    share|cite|improve this answer
























      up vote
      2
      down vote













      I had the same question when I found this, so here's some sample (python) code that would find the nearest divisor with no remainder.



      Num = 636 # Numerator we are seeking to divide with no remainder
      Den = 8 # Initial denominator
      max_iters = 15 # caps the maximum loops
      iters = 1 # initialize counter
      Deni = Dend = Den # vars for searching increasing and decreasing denominators

      while Num%Den != 0:
      Deni +=1 # searching increased vals
      if Dend > 0 : Dend -=1 # searching decreased vals, but check 0 condition
      if Num%Dend ==0: # found a 0 remainder denominator
      Den = Dend # assign found denominator
      break
      elif Num%Deni ==0: # found a 0 remainder denominator
      Den = Deni # assign found denominator
      break
      elif iters >= max_iters: # check loop count
      break
      iters+=1


      Not as clean as a built in function, but hopefully it helps the next person.






      share|cite|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        I had the same question when I found this, so here's some sample (python) code that would find the nearest divisor with no remainder.



        Num = 636 # Numerator we are seeking to divide with no remainder
        Den = 8 # Initial denominator
        max_iters = 15 # caps the maximum loops
        iters = 1 # initialize counter
        Deni = Dend = Den # vars for searching increasing and decreasing denominators

        while Num%Den != 0:
        Deni +=1 # searching increased vals
        if Dend > 0 : Dend -=1 # searching decreased vals, but check 0 condition
        if Num%Dend ==0: # found a 0 remainder denominator
        Den = Dend # assign found denominator
        break
        elif Num%Deni ==0: # found a 0 remainder denominator
        Den = Deni # assign found denominator
        break
        elif iters >= max_iters: # check loop count
        break
        iters+=1


        Not as clean as a built in function, but hopefully it helps the next person.






        share|cite|improve this answer












        I had the same question when I found this, so here's some sample (python) code that would find the nearest divisor with no remainder.



        Num = 636 # Numerator we are seeking to divide with no remainder
        Den = 8 # Initial denominator
        max_iters = 15 # caps the maximum loops
        iters = 1 # initialize counter
        Deni = Dend = Den # vars for searching increasing and decreasing denominators

        while Num%Den != 0:
        Deni +=1 # searching increased vals
        if Dend > 0 : Dend -=1 # searching decreased vals, but check 0 condition
        if Num%Dend ==0: # found a 0 remainder denominator
        Den = Dend # assign found denominator
        break
        elif Num%Deni ==0: # found a 0 remainder denominator
        Den = Deni # assign found denominator
        break
        elif iters >= max_iters: # check loop count
        break
        iters+=1


        Not as clean as a built in function, but hopefully it helps the next person.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Oct 6 '16 at 16:23









        Scout2013

        212




        212












            這個網誌中的熱門文章

            tkz-euclide: tkzDrawCircle[R] not working

            How to combine Bézier curves to a surface?

            1st Magritte Awards