https://github.com/etherbeing/exact_remaining
Simple math formula to get a number that when substracting a percent value it returns the original number
https://github.com/etherbeing/exact_remaining
Last synced: about 1 month ago
JSON representation
Simple math formula to get a number that when substracting a percent value it returns the original number
- Host: GitHub
- URL: https://github.com/etherbeing/exact_remaining
- Owner: etherbeing
- License: bsd-3-clause
- Created: 2022-12-13T19:22:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-13T20:12:22.000Z (over 3 years ago)
- Last Synced: 2025-01-09T03:46:16.651Z (over 1 year ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Exact Remaining
Simple math formula to get a number that when substracting a percent value it returns the original number
# Use cases
The origin of this was thinking how can a seller increase a product price to a total that when substracting a percent from that total the resulting total becomes the wanted total, for example lets say we want to sell a product in 200 $ but for example PayPal will take its 2.9% from that transaction, but we need to sell the product in 200$ because if not we are going to lose money, we want to get an acurrate way of doing so, for that we use the exact remaining formula that give us a number that when substracting a percent amount will going to return us the exact number we want...
with the previous values lets write the math formula:
n = (x*p)/(100-p) where n is number to be added to the total and x is the total and p is the percent someone is going to take from our total
so replacing the previous values in the previous formula we got that
n = ((200*2.9)/(100-2.9))
so n = 5.973223480947477
now if we add n to x we got that
t = n + x
t = 205.97322348094747
finally when substracting the 2.9 percent of t minus t we got the initial x
x = t - ((t*2.9)/100) this is True as left member is equal to right member
when using a language like python for this please use round as some values may get an infinite value as the division is not always exact