Given a the following conditions, how would I go about choosing two values for A and B such that A / B = C:
- A and B are both less than 10
- A and B must have, at most, one decimal place unrounded
- C must have, at most, two decimal places unrounded
Given a the following conditions, how would I go about choosing two values for A and B such that A / B = C:
I went through an Excel spreadsheet and mapped out all the division operations of operands with one decimal place. What I discovered, and there's probably a better explanation for this, is that valid dividends are periodic with respect to the divisor. For instance, consider a divisor of 4.8. According to the criteria I provided, the valid dividends are: 1.2, 2.4, 3.6, 4.8, ..., 9.6. Therefore, when counting in increments of 0.1, every 12th item will be a valid dividend. Moreover, the period is related to the prime factors of the divisor, when converted to an integer. For example, multiplying 4.8 by 10 gives us 48. The prime factorization of 48 is 3, 2, 2, 2, 2. I'm not sure why, but the first two instances of a 2 or a 5 can be ignored for this purpose, but any other prime should be considered. Therefore, the period for this divisor is
3 * 3 * 2 = 12. So, the algorithm for this would work as follows: