The ultimate prompt engineering toolkit for mathematical operations
Stop wrestling with LLMs! awesome-math-prompts generates perfectly crafted, production-ready prompts that guarantee accurate mathematical results from any language model.
✨ Precision Engineered - Every prompt is meticulously designed by mathematicians and prompt engineers to deliver consistent, accurate results
⚡ Zero Configuration - Just call a function, get a world-class prompt. No setup, no fluff.
🎯 Battle Tested - These prompts have been optimized through thousands of LLM interactions to handle edge cases, invalid inputs, and ambiguous scenarios
🚀 Universal Compatibility - Works with OpenAI, Anthropic, Google, and any LLM that eats text prompts
npm install awesome-math-promptsimport { add, subtract, multiply, divide, factorial, fibonacci, isPrime, sqr, randomBtw } from 'awesome-math-prompts';
// Get a ready-to-use prompt for any math operation
const prompt = add(15, 27);
// Returns a fully-formatted prompt that any LLM will understand and execute correctly
// Send the prompt to your LLM
const result = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4"
});
// Result: "42"All functions return a string containing a complete, production-ready prompt.
| Function | Parameters | Description |
|---|---|---|
add(a, b) |
number, number |
Generate a prompt for addition |
subtract(a, b) |
number, number |
Generate a prompt for subtraction |
multiply(a, b) |
number, number |
Generate a prompt for multiplication |
divide(a, b) |
number, number |
Generate a prompt for division |
factorial(n) |
number |
Generate a prompt for factorial calculation |
fibonacci(n) |
number |
Generate a prompt for Fibonacci sequence |
isPrime(n) |
number |
Generate a prompt to check if number is prime |
isEven(n) |
number |
Generate a prompt to check if number is even |
sqr(n) |
number |
Generate a prompt for square root calculation |
randomBtw(a, b) |
number, number |
Generate a prompt for random integer generation |
- Input Validation Built-In - Prompts explicitly tell the LLM how to handle invalid inputs
- Error Handling - Standardized error response format across all operations
- Edge Case Coverage - Division by zero, negative factorials, invalid ranges — handled
- Type Safety - Full TypeScript support with proper type definitions
- Zero Dependencies - Lightweight, no runtime dependencies
Each function generates a structured prompt that:
- Establishes the LLM's role as a mathematics expert
- Clearly defines the expected input format
- Specifies validation rules and error handling
- Provides concrete examples
- Formats the actual operation to perform
MIT