A rational number is a number which can be expressed as a ratio of two integers. In addition, all rational numbers can be expressed as a decimal number with some repeating periodic part (in some cases the repeating part is 0). For example 1/7 = 0.1428571428571428... with 142857 repeating itself infinitely. Other fractions have some finite number of non-repeating digits before the periodic part begins. For example, 1/6 = 0.166666... starts with a 1 and then settles into repeating 6's.
Your task is to write a class Decimal with a method find that takes four int's: lower, upper, lowerLength, and upperLength. Your method must find all integers n between lower and upper, inclusive, where the repeating portion of the decimal representation of 1/n has between lowerLength and upperLength digits, inclusive. You should return all of the numbers you find in a int[] sorted in increasing order.
|