Evening

I am trying to create a class. I am struggling to figure the best flow
to get the maths side to work.

So say that

R is a float given by user input
P is a Total amount(Pool)
Per is a variable %
X is a variable that is a percentage of P defined by a maximum
allocation.

So main = (( R * X)/P)*100

What I want to test is the value of X needed to equal Per from X's
maximum allocation down.

What i am thinking but cant get right

Say

R = 5
P = 10
Per = 190
X = max 80% of P

For X in main = Per ( Closest whole number or half that equals closest
to but greater than Per)
main = (( 5 * 8)/10)*100

So in example intially main equalled 400%. And answer I would want to
resolve it to is X = 4 which is 200% as 3.50 equals 180%.

Any ideas?