Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting random number divisible by 16

Tags:

javascript

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

like image 562
mpri Avatar asked Jan 12 '11 08:01

mpri


People also ask

What numbers can be divisible by 16?

The numbers that 16 is divisible by are 1, 2, 4, 8, and 16.

How do you make a number divisible by 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.

What are the whole numbers less than 100 divisible by 16?

Therefore, the set whole numbers less than 100 divisible by 16​ is {16, 32, 48, 64, 80, 96}.

What number can be divided by 28?

The factors of 28 are the numbers that can evenly divide 28. These factors are 1,2,4,7,14 and 28.


1 Answers

Generate a random integer. Multiply it by 16.

like image 157
Oliver Charlesworth Avatar answered Oct 10 '22 00:10

Oliver Charlesworth