Q: Generate divisor and dividend that generate result with X 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:

*

*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


A: 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:

*

*Choose any random value between 0.1 and 9.9, inclusive at 0.1 intervals.

*Multiply the value by 10

*Find the prime factorization of this value.

*Ignore the first two instances of a 5 or a 2

*Multiply the remaining primes together to find the period

*Choose a random value between 0.1 and 9.9, inclusive at an interval defined by the period and with the first value occurring at the (period - 1)th value

*The value from #1 is the divisor and the value from #6 is the dividend

