Free Fraction Calculator
Use this free online fraction calculator to perform basic arithmetic operations (addition, subtraction, multiplication, and division) on two fractions. Whether you're working with proper fractions, improper fractions, or even whole numbers expressed as fractions, this tool will simplify the process and provide results in their simplest form.
// Function to find the Greatest Common Divisor (GCD) using Euclidean algorithm
function gcd(a, b) {
a = Math.abs(a);
b = Math.abs(b);
while (b) {
var temp = b;
b = a % b;
a = temp;
}
return a;
}
// Function to simplify a fraction
function simplifyFraction(numerator, denominator) {
if (denominator === 0) {
return { numerator: numerator, denominator: 0 }; // Indicate error or undefined
}
if (numerator === 0) {
return { numerator: 0, denominator: 1 };
}
var commonDivisor = gcd(numerator, denominator);
var simplifiedNumerator = numerator / commonDivisor;
var simplifiedDenominator = denominator / commonDivisor;
// Ensure denominator is positive
if (simplifiedDenominator Math.abs(finalDenominator) && finalDenominator !== 0) {
var wholePart = Math.floor(finalNumerator / finalDenominator);
var remainderNumerator = finalNumerator % finalDenominator;
if (remainderNumerator !== 0) {
resultString += " (or " + wholePart + " " + Math.abs(remainderNumerator) + "/" + finalDenominator + ")";
} else {
resultString += " (or " + wholePart + ")";
}
}
resultDiv.innerHTML = "The simplified result is:
" + resultString + "";
}
Understanding Fractions
A fraction represents a part of a whole. It consists of two numbers: a numerator (the top number) and a denominator (the bottom number). The numerator tells you how many parts you have, and the denominator tells you how many equal parts make up the whole.
- Proper Fraction: The numerator is smaller than the denominator (e.g., 1/2, 3/4).
- Improper Fraction: The numerator is equal to or larger than the denominator (e.g., 5/3, 7/7).
- Mixed Number: A whole number and a proper fraction combined (e.g., 1 1/2, 3 2/5).
How to Use the Fraction Calculator
- Enter the First Fraction: Input the numerator and denominator for your first fraction into the respective fields.
- Select an Operation: Choose whether you want to add (+), subtract (-), multiply (*), or divide (/) the fractions using the dropdown menu.
- Enter the Second Fraction: Input the numerator and denominator for your second fraction.
- Calculate: Click the "Calculate Fraction" button to see the result.
The calculator will automatically simplify the result to its lowest terms and, if it's an improper fraction, will also show it as a mixed number.
Fraction Arithmetic Explained
Adding and Subtracting Fractions
To add or subtract fractions, they must have a common denominator. If they don't, you need to find the Least Common Multiple (LCM) of the denominators and convert both fractions to equivalent fractions with that common denominator. Once they have the same denominator, you simply add or subtract the numerators and keep the denominator the same. Finally, simplify the resulting fraction.
Example (Addition): 1/2 + 1/4
- LCM of 2 and 4 is 4.
- Convert 1/2 to 2/4.
- 2/4 + 1/4 = (2+1)/4 = 3/4.
Multiplying Fractions
Multiplying fractions is straightforward: multiply the numerators together to get the new numerator, and multiply the denominators together to get the new denominator. Then, simplify the resulting fraction.
Example (Multiplication): 1/2 * 1/4
- Multiply numerators: 1 * 1 = 1.
- Multiply denominators: 2 * 4 = 8.
- Result: 1/8. (Already simplified)
Dividing Fractions
To divide fractions, you "invert" (flip) the second fraction (the divisor) and then multiply it by the first fraction. This is often remembered as "keep, change, flip." Keep the first fraction, change the division sign to multiplication, and flip the second fraction. Then, simplify the result.
Example (Division): 1/2 / 1/4
- Keep 1/2.
- Change / to *.
- Flip 1/4 to 4/1.
- Now multiply: 1/2 * 4/1 = (1*4)/(2*1) = 4/2.
- Simplify 4/2 to 2.
This calculator handles all these steps for you, making fraction calculations quick and error-free.
.fraction-calculator-container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 25px;
max-width: 700px;
margin: 20px auto;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
color: #333;
}
.fraction-calculator-container h2 {
text-align: center;
color: #0056b3;
margin-bottom: 20px;
font-size: 2em;
}
.fraction-calculator-container h3 {
color: #0056b3;
margin-top: 25px;
margin-bottom: 15px;
font-size: 1.5em;
}
.fraction-calculator-container p {
line-height: 1.6;
margin-bottom: 15px;
}
.calculator-form {
display: flex;
flex-direction: column;
gap: 15px;
margin-bottom: 20px;
padding: 15px;
border: 1px solid #eee;
border-radius: 5px;
background-color: #fff;
}
.fraction-input-group, .operation-select-group {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
}
.fraction-input-group label, .operation-select-group label {
font-weight: bold;
min-width: 120px;
color: #555;
}
.fraction-input-group input[type="number"],
.operation-select-group select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
flex: 1;
min-width: 80px;
box-sizing: border-box;
}
.fraction-input-group input[type="number"]:focus,
.operation-select-group select:focus {
border-color: #007bff;
outline: none;
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
.calculator-form button {
background-color: #28a745;
color: white;
padding: 12px 20px;
border: none;
border-radius: 5px;
font-size: 1.1em;
cursor: pointer;
transition: background-color 0.3s ease;
align-self: center;
width: 100%;
max-width: 250px;
}
.calculator-form button:hover {
background-color: #218838;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
border: 1px solid #d4edda;
background-color: #e2f0e5;
border-radius: 5px;
text-align: center;
}
.calculator-result h3 {
color: #155724;
margin-top: 0;
font-size: 1.3em;
}
.calculator-result p {
font-size: 1.2em;
font-weight: bold;
color: #155724;
margin: 5px 0;
}
.calculator-result .error {
color: #dc3545;
background-color: #f8d7da;
border-color: #f5c6cb;
padding: 10px;
border-radius: 4px;
}
.fraction-calculator-container ul {
list-style-type: disc;
margin-left: 20px;
margin-bottom: 15px;
}
.fraction-calculator-container ol {
list-style-type: decimal;
margin-left: 20px;
margin-bottom: 15px;
}
.fraction-calculator-container li {
margin-bottom: 8px;
line-height: 1.5;
}
@media (max-width: 600px) {
.fraction-input-group, .operation-select-group {
flex-direction: column;
align-items: flex-start;
}
.fraction-input-group label, .operation-select-group label {
min-width: unset;
width: 100%;
margin-bottom: 5px;
}
.fraction-input-group input[type="number"],
.operation-select-group select {
width: 100%;
}
.calculator-form button {
max-width: 100%;
}
}