Random fraction generator

Create random fractions with configurable max denominator and count.

Overview

Fractions have a history that predates any civilization inventing zero. Ancient Egyptians used exclusively unit fractions — fractions with numerator 1: ½, ⅓, ¼ — and represented any fraction as a sum of them. The Rhind Papyrus, dated around 1650 BCE, contains an entire table of decompositions of fractions into sums of unit fractions. Euclid, around 300 BCE, formalized in Book VII of the Elements the algorithm for computing the Greatest Common Divisor (GCD) — which is exactly what we use today to simplify fractions. Euclid's algorithm, over 2,300 years old, is arguably the oldest mathematical algorithm still in active use. Rationals — numbers expressible as a fraction of two integers — are theoretically the easiest numbers to represent exactly. In practice, modern computers prefer floating-point.

The IEEE 754 standard, published in 1985, defines how computers represent floating-point numbers in binary — and this is where the simplicity of fractions falls apart. The number 0.1 in decimal has no exact representation in 32- or 64-bit binary, just as ⅓ has no exact representation in decimal. That is why in JavaScript (and in virtually every language following IEEE 754), `0.1 + 0.2` equals `0.30000000000000004`, not `0.3`. This is one of the most famous and misunderstood bugs in programming — every week someone discovers it for the first time and concludes the language is broken. Representing fractions as an integer pair (numerator/denominator) avoids this problem entirely: 1/3 plus 1/6 is exactly 1/2, with no rounding error whatsoever.

Fractions appear in surprising contexts outside school mathematics. Musical time signatures (3/4 or 4/4 time), aspect ratio proportions (16:9 is the same as 16/9), probability fractions in statistics, recipes scaled by a fraction (¾ of the original recipe), CSS layout fractions (`grid-template-columns: 1fr 2fr`). For developers building educational simulators, exercise generators, or testing fractional calculation logic, needing random fractions with varied denominators is a practical requirement. This tool generates fractions with denominators up to the value you choose, already simplified by GCD, in configurable quantities — ready for exercises, tests, or any context that needs varied rational numbers.

Technical deep dive

Common questions summarized

  • What is this tool for?: It runs fully in your browser: useful to validate, format, or convert data in everyday development.
  • Are my inputs sent to a server?: Processing happens locally with JavaScript. We do not store what you paste into the text areas.
  • Can I use this for real production data?: Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.

Sample payload to try

  • See also the larger "Code Snippets" sample; paste this excerpt to try locally: Example — 5 frações com denominador até 20

Tool guide

  • What a fraction is A ratio between two integers in numerator/denominator format.

  • What the tool does Generates random fractions with configurable denominator cap and quantity.

  • Why use it Educational exercises, test data, and simple numeric simulations.

Code Snippets

Code example
5 frações com denominador até 20

Example

5 frações com denominador até 20

FAQ

What is this tool for?

It runs fully in your browser: useful to validate, format, or convert data in everyday development.

Are my inputs sent to a server?

Processing happens locally with JavaScript. We do not store what you paste into the text areas.

Can I use this for real production data?

Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.