Number Sequence Generator
Generate arithmetic, geometric, Fibonacci, and prime number sequences.
About this tool
A number sequence generator is a tool that creates ordered lists of numbers following mathematical patterns. Whether you need arithmetic progressions for basic calculations, geometric sequences for exponential growth modeling, Fibonacci numbers for nature-inspired algorithms, or prime numbers for cryptography and coding challenges, this tool generates them instantly without requiring manual computation.
To use this tool, select your desired sequence type from the dropdown menu, then enter parameters like the starting value, common difference or ratio, and how many terms you want to generate. The tool will immediately display the sequence in a clear list, making it easy to copy the results for use in spreadsheets, programming projects, or mathematical analysis.
Frequently Asked Questions
Code Implementation
def arithmetic_nth(a, d, n):
"""n-th term of arithmetic sequence (1-indexed)."""
return a + (n - 1) * d
def arithmetic_sum(a, d, n):
"""Sum of first n terms of arithmetic sequence."""
return n * (2 * a + (n - 1) * d) / 2
def geometric_nth(a, r, n):
"""n-th term of geometric sequence (1-indexed)."""
return a * (r ** (n - 1))
def geometric_sum(a, r, n):
"""Sum of first n terms of geometric sequence."""
if r == 1:
return a * n
return a * (1 - r ** n) / (1 - r)
def fibonacci(n):
"""Generate first n Fibonacci numbers."""
seq = [0, 1]
for _ in range(n - 2):
seq.append(seq[-1] + seq[-2])
return seq[:n]
def detect_sequence(seq):
"""Auto-detect if sequence is arithmetic, geometric, or other."""
diffs = [seq[i+1] - seq[i] for i in range(len(seq) - 1)]
if len(set(diffs)) == 1:
return "arithmetic", diffs[0]
ratios = [seq[i+1] / seq[i] for i in range(len(seq) - 1) if seq[i] != 0]
if len(set(round(r, 9) for r in ratios)) == 1:
return "geometric", ratios[0]
return "other", None
# Examples
print(arithmetic_nth(2, 3, 5)) # 14 (2,5,8,11,14)
print(arithmetic_sum(1, 1, 100)) # 5050 (Gauss sum)
print(geometric_sum(1, 0.5, float("inf"))) # use formula: 1/(1-0.5)=2
print(geometric_sum(1, 2, 10)) # 1023
print(fibonacci(10)) # [0,1,1,2,3,5,8,13,21,34]
print(detect_sequence([3,6,12,24])) # ('geometric', 2.0)Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.