For whole numbers a, b you can convert them to a percentage a/b that is then rounded to a whole percent.
Suppose you know a/b = 24%, it may be that b=21 since 5/21 = .238095... but b could not be 22 since 5/22=23% and 6/22=27%.
Still using 24%:
[1] What is the smallest possible value of b?
[2] What is the largest value that b could not be?
Now find the 5 percentages between 0 and 50
[3] that give the largest answers to part [1]?
[4] that give the smallest answers to part [2]?
Part 1:
The table below shows the minimum b to allow rounding to the given percent:
% a b a/b
1 1/67 a/b = 1.4925373134%
2 1/41 a/b = 2.4390243902%
3 1/29 a/b = 3.4482758621%
4 1/23 a/b = 4.3478260870%
5 1/19 a/b = 5.2631578947%
6 1/16 a/b = 6.2500000000%
7 1/14 a/b = 7.1428571429%
8 1/12 a/b = 8.3333333333%
9 1/11 a/b = 9.0909090909%
10 1/10 a/b = 10.0000000000%
11 1/ 9 a/b = 11.1111111111%
12 2/17 a/b = 11.7647058824%
13 1/ 8 a/b = 12.5000000000%
14 1/ 7 a/b = 14.2857142857%
15 2/13 a/b = 15.3846153846%
16 3/19 a/b = 15.7894736842%
17 1/ 6 a/b = 16.6666666667%
18 2/11 a/b = 18.1818181818%
19 3/16 a/b = 18.7500000000%
20 1/ 5 a/b = 20.0000000000%
21 3/14 a/b = 21.4285714286%
22 2/ 9 a/b = 22.2222222222%
23 3/13 a/b = 23.0769230769%
24 4/17 a/b = 23.5294117647%
25 1/ 4 a/b = 25.0000000000%
26 5/19 a/b = 26.3157894737%
27 3/11 a/b = 27.2727272727%
28 5/18 a/b = 27.7777777778%
29 2/ 7 a/b = 28.5714285714%
30 3/10 a/b = 30.0000000000%
31 4/13 a/b = 30.7692307692%
32 6/19 a/b = 31.5789473684%
33 1/ 3 a/b = 33.3333333333%
34 10/29 a/b = 34.4827586207%
35 6/17 a/b = 35.2941176471%
36 4/11 a/b = 36.3636363636%
37 7/19 a/b = 36.8421052632%
38 3/ 8 a/b = 37.5000000000%
39 7/18 a/b = 38.8888888889%
40 2/ 5 a/b = 40.0000000000%
41 7/17 a/b = 41.1764705882%
42 5/12 a/b = 41.6666666667%
43 3/ 7 a/b = 42.8571428571%
44 4/ 9 a/b = 44.4444444444%
45 5/11 a/b = 45.4545454545%
46 6/13 a/b = 46.1538461538%
47 7/15 a/b = 46.6666666667%
48 10/21 a/b = 47.6190476190%
49 17/35 a/b = 48.5714285714%
50 1/ 2 a/b = 50.0000000000%
so for 24%, the minimum b is 17 as 4/17 ~= 23.5294117647%
Part 2:
The table for this is:
nearest
% a's b lower a/b higher a/b
1 0 1/66 a/b = 0.0000000000% 1.5151515152%
2 1 2/80 a/b = 1.2500000000% 2.5000000000%
3 2 3/85 a/b = 2.3529411765% 3.5294117647%
4 3 4/88 a/b = 3.4090909091% 4.5454545455%
5 4 5/90 a/b = 4.4444444444% 5.5555555556%
6 5 6/92 a/b = 5.4347826087% 6.5217391304%
7 6 7/93 a/b = 6.4516129032% 7.5268817204%
8 7 8/94 a/b = 7.4468085106% 8.5106382979%
9 7 8/84 a/b = 8.3333333333% 9.5238095238%
10 9 10/95 a/b = 9.4736842105% 10.5263157895%
11 9 10/86 a/b = 10.4651162791% 11.6279069767%
12 11 12/96 a/b = 11.4583333333% 12.5000000000%
13 10 11/81 a/b = 12.3456790123% 13.5802469136%
14 12 13/89 a/b = 13.4831460674% 14.6067415730%
15 13 14/90 a/b = 14.4444444444% 15.5555555556%
16 13 14/84 a/b = 15.4761904762% 16.6666666667%
17 16 17/97 a/b = 16.4948453608% 17.5257731959%
18 15 16/86 a/b = 17.4418604651% 18.6046511628%
19 17 18/92 a/b = 18.4782608696% 19.5652173913%
20 15 16/78 a/b = 19.2307692308% 20.5128205128%
21 19 20/93 a/b = 20.4301075269% 21.5053763441%
22 18 19/84 a/b = 21.4285714286% 22.6190476190%
23 20 21/89 a/b = 22.4719101124% 23.5955056180%
24 19 20/81 a/b = 23.4567901235% 24.6913580247%
25 24 25/98 a/b = 24.4897959184% 25.5102040816%
26 21 22/83 a/b = 25.3012048193% 26.5060240964%
27 23 24/87 a/b = 26.4367816092% 27.5862068966%
28 25 26/91 a/b = 27.4725274725% 28.5714285714%
29 25 26/88 a/b = 28.4090909091% 29.5454545455%
30 28 29/95 a/b = 29.4736842105% 30.5263157895%
31 28 29/92 a/b = 30.4347826087% 31.5217391304%
32 28 29/89 a/b = 31.4606741573% 32.5842696629%
33 25 26/77 a/b = 32.4675324675% 33.7662337662%
34 28 29/84 a/b = 33.3333333333% 34.5238095238%
35 31 32/90 a/b = 34.4444444444% 35.5555555556%
36 33 34/93 a/b = 35.4838709677% 36.5591397849%
37 35 36/96 a/b = 36.4583333333% 37.5000000000%
38 31 32/83 a/b = 37.3493975904% 38.5542168675%
39 35 36/91 a/b = 38.4615384615% 39.5604395604%
40 31 32/79 a/b = 39.2405063291% 40.5063291139%
41 36 37/89 a/b = 40.4494382022% 41.5730337079%
42 39 40/94 a/b = 41.4893617021% 42.5531914894%
43 36 37/85 a/b = 42.3529411765% 43.5294117647%
44 40 41/92 a/b = 43.4782608696% 44.5652173913%
45 40 41/90 a/b = 44.4444444444% 45.5555555556%
46 40 41/88 a/b = 45.4545454545% 46.5909090909%
47 39 40/84 a/b = 46.4285714286% 47.6190476190%
48 37 38/78 a/b = 47.4358974359% 48.7179487179%
49 32 33/66 a/b = 48.4848484848% 50.0000000000%
50 49 50/99 a/b = 49.4949494949% 50.5050505051%
So for 24%, 19/81 = 23.4567901235% and 20/81 = 24.6913580247%, so the answer to part 2 is 81, as the highest b that doesn't have a valid a.
Part 3:
Sorting gives these top 5:
1 1/67 a/b = 1.4925373134%
2 1/41 a/b = 2.4390243902%
49 17/35 a/b = 48.5714285714%
3 1/29 a/b = 3.4482758621%
34 10/29 a/b = 34.4827586207%
1% requires b be at least 67.
2% requires b be at least 41.
49% requires b be at least 35.
3% requires b be at least 29.
34% requires b be at least 29.
Part 4:
Sorting the second table gives these bottom 5:
49 32 33/66 a/b = 48.4848484848% 50.0000000000%
1 0 1/66 a/b = 0.0000000000% 1.5151515152%
33 25 26/77 a/b = 32.4675324675% 33.7662337662%
20 15 16/78 a/b = 19.2307692308% 20.5128205128%
48 37 38/78 a/b = 47.4358974359% 48.7179487179%
so the order here is 49% and 1% with b=66, 33% with b=77 and 20% and 48% with b=78.
DEFDBL A-Z
OPEN "ppctpt1.txt" FOR OUTPUT AS #2
' parts 1 and 3
FOR pct = 1 TO 50
FOR b = 1 TO 1000
a0 = b * pct / 100
a1 = INT(a0): a2 = -INT(-a0)
pct1 = INT(a1 * 100 / b + .5): pct2 = INT(a2 * 100 / b + .5)
IF pct1 = pct OR pct2 = pct THEN
IF pct1 = pct THEN a = a1: ELSE a = a2
EXIT FOR
END IF
NEXT b
PRINT #2, USING "## ##&##&##.##########&"; pct; a; "/"; b; " a/b = "; a * 100 / b; "%"
NEXT pct
' parts 2 and 4
FOR pct = 1 TO 50
FOR b = 99 TO 1 STEP -1
a0 = b * pct / 100
a1 = INT(a0): a2 = -INT(-a0)
pct1 = INT(a1 * 100 / b + .5): pct2 = INT(a2 * 100 / b + .5)
IF pct1 < pct AND pct2 > pct THEN
EXIT FOR
END IF
NEXT b
PRINT #2, USING "## ## ##&##&##.##########& ##.##########&"; pct; a1; a2; "/"; b; " a/b = "; a1 * 100 / b; "%"; a2 * 100 / b; "%"
NEXT pct
|
Posted by Charlie
on 2010-01-08 14:15:30 |