In math how do I obtain the closest number of a number that is divisible by 16?
For example I get the random number 100 and I want to turn that number (using a math function) into the closest number to 100 that is divisible by 16 (In this case its 96)
I'm trying to do this in JavaScript but if I knew the math formula for it I would easily do it in any language.
Thank you, Regards
The numbers that 16 is divisible by are 1, 2, 4, 8, and 16.
A number is divisible by 16 if the thousands digit is even and the last three digits form a number that is divisible by 16. A number is also divisible by 16 if the thousands digit is odd and the number formed by the last three digits plus 8 is divisible by 16.
Therefore, the set whole numbers less than 100 divisible by 16 is {16, 32, 48, 64, 80, 96}.
The factors of 28 are the numbers that can evenly divide 28. These factors are 1,2,4,7,14 and 28.
Generate a random integer. Multiply it by 16.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With