Sequences are ordered lists of numbers that follow a specific pattern or rule. Each number in the sequence is called a term. The study of sequences and their sums (known as series) is a fundamental part of mathematics, with applications in finance, computer science, physics, and more. This calculator helps you explore three common types of sequences: Arithmetic, Geometric, and Fibonacci.
Arithmetic Sequences
An arithmetic sequence is a sequence of numbers such that the difference between consecutive terms is constant. This constant difference is called the common difference, denoted by d.
The formula to find the Nth term (an) of an arithmetic sequence is:
an = a₁ + (n - 1)d
Where:
an is the Nth term
a₁ is the first term
n is the term number you want to find
d is the common difference
Example: Find the 10th term of an arithmetic sequence where the first term is 3 and the common difference is 5.
a₁ = 3, d = 5, n = 10 a₁₀ = 3 + (10 - 1) * 5 = 3 + 9 * 5 = 3 + 45 = 48
Geometric Sequences
A geometric sequence is a sequence of numbers where each term after the first is found by multiplying the previous one by a fixed, non-zero number called the common ratio, denoted by r.
The formula to find the Nth term (an) of a geometric sequence is:
an = a₁ * r(n - 1)
Where:
an is the Nth term
a₁ is the first term
n is the term number you want to find
r is the common ratio
Example: Find the 5th term of a geometric sequence where the first term is 2 and the common ratio is 3.
a₁ = 2, r = 3, n = 5 a₅ = 2 * 3(5 - 1) = 2 * 34 = 2 * 81 = 162
Fibonacci Sequence
The Fibonacci sequence is a special sequence where each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence typically begins: 0, 1, 1, 2, 3, 5, 8, 13, 21, …
The rule is:
Fn = Fn-1 + Fn-2
With initial conditions:
F₀ = 0
F₁ = 1
(Note: Some definitions start with F₁ = 1 and F₂ = 1, which shifts the sequence slightly.)
Education: Helping students understand and practice sequence calculations.
Computer Science: Analyzing algorithms, data structures, and computational complexity.
Finance: Modeling compound interest (geometric) or irregular payment patterns.
Biology: Observing patterns in natural phenomena, like branching in trees or population growth.
Art and Design: Applying mathematical patterns for aesthetic purposes.
function updateInputs() {
var type = document.getElementById("sequenceType").value;
document.getElementById("arithmeticInputs").style.display = (type === "arithmetic") ? "block" : "none";
document.getElementById("geometricInputs").style.display = (type === "geometric") ? "block" : "none";
document.getElementById("fibonacciInputs").style.display = (type === "fibonacci") ? "block" : "none";
// Clear previous results when changing type
document.getElementById("result").innerHTML = "";
document.getElementById("sequenceResult").innerHTML = "";
}
function calculateSequence() {
var type = document.getElementById("sequenceType").value;
var resultHTML = "";
var sequenceResultHTML = "";
try {
if (type === "arithmetic") {
var a1 = parseFloat(document.getElementById("arithmeticFirstTerm").value);
var d = parseFloat(document.getElementById("arithmeticCommonDiff").value);
var n = parseInt(document.getElementById("arithmeticTermNumber").value);
if (isNaN(a1) || isNaN(d) || isNaN(n) || n <= 0) {
resultHTML = "Please enter valid numbers for all fields and a positive term number (n).";
} else {
var an = a1 + (n – 1) * d;
resultHTML = "The " + n + "th term (a" + n + ") is: " + an + "";
}
} else if (type === "geometric") {
var a1 = parseFloat(document.getElementById("geometricFirstTerm").value);
var r = parseFloat(document.getElementById("geometricCommonRatio").value);
var n = parseInt(document.getElementById("geometricTermNumber").value);
if (isNaN(a1) || isNaN(r) || isNaN(n) || n <= 0) {
resultHTML = "Please enter valid numbers for all fields and a positive term number (n).";
} else {
var an = a1 * Math.pow(r, n – 1);
resultHTML = "The " + n + "th term (a" + n + ") is: " + an + "";
}
} else if (type === "fibonacci") {
var n = parseInt(document.getElementById("fibonacciTermNumber").value);
if (isNaN(n) || n < 0) {
resultHTML = "Please enter a non-negative integer for the term number (n).";
} else {
if (n === 0) {
sequenceResultHTML = "F0 = 0″;
} else if (n === 1) {
sequenceResultHTML = "F1 = 1″;
} else {
var fib = [0, 1];
for (var i = 2; i <= n; i++) {
fib[i] = fib[i – 1] + fib[i – 2];
}
sequenceResultHTML = "F" + n + " = " + fib[n];
}
resultHTML = "The " + n + "th Fibonacci number is: " + sequenceResultHTML + "";
}
}
} catch (e) {
resultHTML = "An error occurred during calculation. Please check your inputs.";
console.error(e);
}
document.getElementById("result").innerHTML = resultHTML;
}
// Initialize input visibility on page load
document.addEventListener('DOMContentLoaded', updateInputs);