Back to articles
Three Percentage Formulas That Cover Every Situation
News

Three Percentage Formulas That Cover Every Situation

via Dev.to BeginnersMichael Lip

Every percentage problem reduces to one of three questions. What is X percent of Y. What percent is X of Y. Y is X percent of what number. Three formulas. That covers every percentage calculation you will ever encounter. The three formulas What is X% of Y? Result = (X / 100) * Y What is 15% of 200? → (15/100) * 200 = 30 What percent is X of Y? Percent = (X / Y) * 100 What percent is 30 of 200? → (30/200) * 100 = 15% Y is X% of what? Total = Y / (X / 100) 30 is 15% of what? → 30 / (15/100) = 200 function percentOf ( percent , total ) { return ( percent / 100 ) * total ; } function whatPercent ( part , total ) { return ( part / total ) * 100 ; } function percentOfWhat ( part , percent ) { return part / ( percent / 100 ); } Percentage change Change = ((New - Old) / Old) * 100 From 80 to 100: ((100 - 80) / 80) * 100 = 25% increase From 100 to 80: ((80 - 100) / 100) * 100 = 20% decrease Note the asymmetry: a 25% increase followed by a 20% decrease returns to the original value. They are not

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
8 views

Related Articles