Skip to content

getbodya/awesome-math-prompts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-prompts

Usage

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:

  1. Establishes the LLM's role as a mathematics expert
  2. Clearly defines the expected input format
  3. Specifies validation rules and error handling
  4. Provides concrete examples
  5. Formats the actual operation to perform

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors