Algorithm for Generating Percentage Amounts

mardi 28 janvier 2014

Hey guys,



Not totally sure this thread belongs in this section, feel free to move.



I'm trying to formulate an algorithm for an unusual problem.



- Generate a pie chart with X number of wedges.

- Each wedge is X percentage bigger then the one before it.

- Percentage amounts of all wedges must add up to 100 (thereby completing the pie chart)



So for example, in Excel I can create a pie chart with 5 wedges, and each wedge is 20% bigger then the previous one. It gives me these numbers (rounded).



Wedge 1: 13.43797%

Wedge 2: 16.125564%

Wedge 3: 19.3506768%

Wedge 4: 23.22081216%

Wedge 5: 27.86497459%



But I got that result by trial and error of Wedge 1's value until the final output of the pie chart hit 100%. How do I calculate Wedge 1's value simply based off the number of wedges in the pie, and the percentage amounts from one wedge to the next?



I appreciate any help you guys can provide =]





0 commentaires:

Enregistrer un commentaire