0

Hi i'm not english so I'll try to explain this as good as I can .

If we have for example

250 : 5 = 50 , remainder 0

let's say I don't know the number i'm going to divide (because it is generated random or it changes) , but I know that I want a reimander of the division equal to 0

so N : X = A , with R = 0

I need a formula or a way to find the X that gives to me R = 0

Jyrki Lahtonen
  • 133,153
Hammond95
  • 103
  • The first answer posted says essentially all there is to be said in answer to the question as initially described. If you want anything more, it might help to give more details about why you want to divide a random number evenly. Presumably you have a particular application in mind, but you don't say what. – David K Nov 24 '14 at 02:36

1 Answers1

0

You want to find a divisor for an arbitrary integer, that's how it's normally called.

If you allow X to be N or 1, then you are OK. If you don't allow that, you might find some cases where it's not possible, those are called "prime numbers"; for example there is no integer except 1 and 13 that divide 13 with remainder 0.

An easy algorithm is to test all the odd numbers from 3 to the square root of N. Checking for divisibility is very quick, you don't need to perform the division, just additions and multiplications.

rewritten
  • 3,092