Pure Programmer
Blue Matrix


Cluster Map

Project: Renard Numbers (Preferred Numbers)

Write a program that computes the Renard (Preferred) Numbers between 1 and 1000. The user should be allowed to specify the series R5, R10, R20 or R40 on the command line by passing a single argument of 5, 10, 20 or 40. This argument specifies how many divisions should be made in the interval 1 to 10. These preferred numbers are computed as a geometric series using a factor of the 5th, 10th, 20th or 40th root of 10. Preferred numbers in the range 10-100, and 100-1000 are computed by multiplying the values in the range 1-10 by factors of 10 and 100 respectively. By computing the values in the range 1-10 and storing them in an array makes it easy to compute the values in the other ranges.

The perfect numbers are typically rounded to a small number of decimal places. You can use formatted output to round the values on output to the desired number of decimal places. The user should be allowed to specify on the command line a second argument that dictates the number of decimal places to round on output.

See [[Renard Numbers]]

Output
$ python3 RenardNumbers1.py 5 1 R5: 1.0, 1.6, 2.5, 4.0, 6.3, 10, 16, 25, 40, 63, 100, 158, 251, 398, 631, 1000 $ python3 RenardNumbers1.py 5 2 R5: 1.00, 1.58, 2.51, 3.98, 6.31, 10.0, 15.8, 25.1, 39.8, 63.1, 100, 158, 251, 398, 631, 1000 $ python3 RenardNumbers1.py 10 2 R10: 1.00, 1.26, 1.58, 2.00, 2.51, 3.16, 3.98, 5.01, 6.31, 7.94, 10.0, 12.6, 15.8, 20.0, 25.1, 31.6, 39.8, 50.1, 63.1, 79.4, 100, 126, 158, 200, 251, 316, 398, 501, 631, 794, 1000 $ python3 RenardNumbers1.py 20 2 R20: 1.00, 1.12, 1.26, 1.41, 1.58, 1.78, 2.00, 2.24, 2.51, 2.82, 3.16, 3.55, 3.98, 4.47, 5.01, 5.62, 6.31, 7.08, 7.94, 8.91, 10.0, 11.2, 12.6, 14.1, 15.8, 17.8, 20.0, 22.4, 25.1, 28.2, 31.6, 35.5, 39.8, 44.7, 50.1, 56.2, 63.1, 70.8, 79.4, 89.1, 100, 112, 126, 141, 158, 178, 200, 224, 251, 282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000 $ python3 RenardNumbers1.py 40 3 R40: 1.000, 1.059, 1.122, 1.189, 1.259, 1.334, 1.413, 1.496, 1.585, 1.679, 1.778, 1.884, 1.995, 2.113, 2.239, 2.371, 2.512, 2.661, 2.818, 2.985, 3.162, 3.350, 3.548, 3.758, 3.981, 4.217, 4.467, 4.732, 5.012, 5.309, 5.623, 5.957, 6.310, 6.683, 7.079, 7.499, 7.943, 8.414, 8.913, 9.441, 10.00, 10.59, 11.22, 11.89, 12.59, 13.34, 14.13, 14.96, 15.85, 16.79, 17.78, 18.84, 19.95, 21.13, 22.39, 23.71, 25.12, 26.61, 28.18, 29.85, 31.62, 33.50, 35.48, 37.58, 39.81, 42.17, 44.67, 47.32, 50.12, 53.09, 56.23, 59.57, 63.10, 66.83, 70.79, 74.99, 79.43, 84.14, 89.13, 94.41, 100.0, 105.9, 112.2, 118.9, 125.9, 133.4, 141.3, 149.6, 158.5, 167.9, 177.8, 188.4, 199.5, 211.3, 223.9, 237.1, 251.2, 266.1, 281.8, 298.5, 316.2, 335.0, 354.8, 375.8, 398.1, 421.7, 446.7, 473.2, 501.2, 530.9, 562.3, 595.7, 631.0, 668.3, 707.9, 749.9, 794.3, 841.4, 891.3, 944.1, 1000

Solution