Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write a calculation for a program code but cannot figure out how the math would work. My goal is to have a calculation that would read something like value A is greater than value b by 300% or more.

I know this is a mathematics forum but if it helps the code is in python and would be an if statement like:

if value a is greater than value b by 300% or more then violation, else not a violation.
share|cite|improve this question
sorry about my bad explanation, im having trouble putting it into words how i need it and am trying to avoid programming language specific stuff, been a while since i had a math class – wondergoat77 Sep 19 '12 at 17:00
$300\%$ of $b$? So for example, if $b=3$, do you want $a$ at most $3+9=12$? – David Mitra Sep 19 '12 at 17:21
up vote 1 down vote accepted
if b*3<a then

This will check if a is 3 times larger than b since $a*300\% = a*3$.

share|cite|improve this answer
This is checking if $b$ is $300\%$ of $a$, not whether it is $300\%$ more than $a$. Sometimes people are not careful about the wording and what you do may be what OP intended. – Ross Millikan Sep 19 '12 at 17:35
thanks, this did the trick. – wondergoat77 Sep 19 '12 at 18:00

When we say a percentage like 300% what we really mean is 3*(100%). You would just take the value of $b$ (which is 100%) and multiply it by 3 and then add that to $b$. In Python this would look something like this:

if a >= 3*b+b:
    print "Violation"
    print "Not a violation"
share|cite|improve this answer
wouldnt that add up to 400% though, essentially a> 300% + 100%? – wondergoat77 Sep 19 '12 at 17:36
Yes, 400% of $b$ is 300% more than $b$. In other words if a store has a 30% off sale, you pay $price-.3*price$, and not $.3*price$. – noahklein Sep 19 '12 at 17:43
ok, my fault there then, i explained it incorrectly for what i needed, but your answer was helpful none the less. thanks. – wondergoat77 Sep 19 '12 at 18:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.