awesome-math-prompts
v1.0.0
Published
Prompt engineering toolkit for mathematical operations - generates production-ready prompts for LLMs
Maintainers
Readme
awesome-math-prompts
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.
Why This Is The Best Math Prompt Library
✨ 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
Installation
npm install awesome-math-promptsUsage
import { 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"API Reference
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 |
Features
- 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
How It Works
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
License
MIT
