October 10, 20196 yr Here's my scenario, I need to divide a number that could result as nearest as 12 but nut exceed to 12 Example 50 / 5 = 10 70 / 7 = 11.66 What i need is the divisor to put so the result would be as nearest as 12 not equal or greater than 12.
October 10, 20196 yr 4 hours ago, archrid404 said: 70 / 7 = 11.66 I don't think so. Assuming you want a whole divisor that returns a result closest to 12 but never equal to or greater than 12, start by dividing the number by 12. If the result is a whole number, bump it up by 1. Otherwise bump it up to the nearest whole number: Let ( divisor = number / 12 ; If ( Mod ( divisor ; 1 ) ; Ceiling ( divisor ) ; divisor + 1 ) ) Or shortly: Div ( number ; 12 ) + 1 This will produce a divisor of 5 for the number 50 (50/5 = 10) and 6 for the number of 70 (70/6=11.6666666666666667). Edited October 10, 20196 yr by comment
Create an account or sign in to comment