How can i separate a bigger number to small numbers in PHP?

If i have for example the number 20.

what is the calc to get 8 + 8 + 4?

or

42 = 8 + 8 + 8 + 8 + 8 + 2

the numbers keys are 8 and 4.

floor(20/8) gives you the number of 8s required. 20 % 8 gives you the remainder. then you repeat this process with the next number (4) until the remainder is 0.

2 Likes

Thanks man. you are the best

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.